#1 2022-11-12 01:09

jogiwer
Member
From: Germany
Registered: 2022-11-05
Posts: 66

Poor mans way to watch the progress

In this post I asked for something like this:

  1. preview might take a while using complex rules with scripts and/or external tools. I allready read the a process bar is hard to implement. Nevertheless I'd like to add:

    1. Next to showing the progress there should be also a way to stop the step

    2. It could also help to add the new names to the list as they are build. So one could see the progress in the list which should be scrollable while in the step.

    3. As new names are added one could check the quality of the renaming and might want to stop the task on bad results

    4. Maybe it is an idea to put a specal command to PascalScript that could do some updates to the gui, handle any cancel request ...
      Just like a dialog but it should hold the flow or need action for every single file.

You (Denis) stated that this is on the "to do" list but with a low priority.

Now I can come around with a solution which is not as smooth as a progress bar but serves the following:

  • Show new names inbetween, so the preview has not to run over all files

  • Give an option to stop previewing

This should be placed as last rule so the new FileName is fully prepared:

(*   Poor mans progress bar
 *
 *   user could input a blocksize n
 *   every n files a Dialog will be shown
 *   - Numbers of files that have been processed so far
 *   - Old and new filenames for these files
 *     Where "new filename" might not be the result of
 *     the whole preview as it depends on where you place
 *     this rule/script.
 *   - A new value for the blocksize could be entered.
 *     The old value is placed as default and could be keep.
 *   - If something seems to behave wrong the "cancel"
 *     button could be used to end the preview with an error.
 *)
var
  Initialized: Boolean;

  (* all the Files being processed *)
  Marked: TWideStringArray;

  (* user is setting the behaviour *)
  Input: WideString;
  BlockSize: Integer;
  Pos: Integer;

  (* each block collects some info to output *)
  FileInfo: TWideStringArray;

function InitNextBlock(const Input: WideString): Integer;
begin
    BlockSize := StrToInt(Input);
    SetLength(FileInfo, BlockSize);
    Pos := 0;
    Result := BlockSize;
end;

function GetFileInfo(): WideString;
begin
  Result := IntToStr(GetCurrentMarkedFileIndex) + '/' + IntToStr(GetTotalNumberOfMarkedFiles)
              + ' "' + WideExtractFileName(Marked[Pos]) + '" -> "' + FileName + '"';
end;

begin
  (* Initialization *)
  if not Initialized then
  begin
    Marked := GetMarkedFiles;
    Input  := WideInputBox('Inspect:', 'Show new names every <n> files. Or "0" without stops.', '0');
    InitNextBlock(Input);

    Initialized := True
  end;

  (* if in block mode *)
  if BlockSize > 0 then
  begin
    FileInfo[Pos] := GetFileInfo();
    Inc(Pos);

    (* is the block completed *)
    if Pos = BlockSize then
    begin
      if not WideInputQuery('Progress:', WideJoinStrings(FileInfo, #13) + #13#13'Next blocksize?', Input) then
      begin
        Error('Abbruch');
      end;
      InitNextBlock(Input);
    end;
  end;
end.

Last edited by jogiwer (2022-11-16 11:46)

Offline

#2 2022-11-12 01:25

jogiwer
Member
From: Germany
Registered: 2022-11-05
Posts: 66

Re: Poor mans way to watch the progress

Are these possible improvements?:

  1. If there were a timeout option for the dialogs ...

  2. I did not manage to get only one filename with GetMarkedFile[Pos]. So as a PascalScript rookie I don't know if it should be possible to directly access a slot from the array returned by a function or if it is needed to get a copy.

  3. There is no way to get the real new name in terms of functions likely to GetMarkedFiles.
    GetNewNameForFile(Integer)
    Such function could also help for a solution on the group-of-files-problem (same name, different ext)

Offline

Board footer

Powered by FluxBB