Resource

Resource Basics

Resource Name Make Files Read Only
Resource Version 1.1
Category File System
Downloads 728
Release Date 9/9/2022 1:13:23 AM
 

Resource Details

Description This script makes the selected files "read-only"
Installation Instructions In Photo Supreme:
1. Select the thumbs to change the file stamps for
2. Right click on a selected thumb
3. Select Run Script from Repository
4. Select File System -> Change File Dates to Photo Date
Usage Instructions n.a.
Changes in this version Version 1.1
Change to comply with v2024
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

{
    Initial Date: 09 sep 2022

    Version history:
        1.0
            Author: IDimager
            09 sep 2022;
            initial version

        1.1
            Author: IDimager
            10 Mar 2024;
            Made compatible with PSU2024
}

  function HandleImageItem(AImageItem: TImageItem): Boolean;
  begin
    result := False;
    if not AImageItem.MediumLoaded then exit;

    result := AImageItem.FileReadOnly(True);
  end;

var
  i, AHit: Integer;
  AProgress: TxomProgress;
begin
  if Selected.Count = 0 then
  begin
    Say ('No images selected');
    exit;
  end;

  if not Ask('This script changes the file read-only state for the ' + IntToStr(Selected.Count) + ' selected thumbnails.' + CrLf2 + 'Are you sure you want to continue?') then
    exit;

  AProgress := TxomProgress.Create(nil);
  try
    AProgress.Caption := 'Make Files Read Only';
    AProgress.Cancel := False;
    AProgress.ProgressBar := True;
    AProgress.Max := Selected.Count;
    AProgress.Show;

    AHit := 0;
    for i := 0 to Selected.Count - 1 do
    begin
      AProgress.ProgressText := Selected.Items[i].FileName;
      AProgress.Pos := i + 1;
      if AProgress.Cancel then
        break;

      if HandleImageItem(Selected.Items[i]) then
        Inc(AHit);
    end;

    AProgress.Hide;
    if AProgress.Cancel then
      Say2('Cancelled', 'Read-only for ' + IntToStr(AHit) + ' files was changed.')
    else
      SendVisualFeedback('Read-only for ' + IntToStr(AHit) + ' files was changed.', 3000);
  finally
    AProgress.Free;
  end;
end;