Page 1 of 1

<Solved>Script batch rename problem

Posted: 11 May 2022 14:06
by Norn
Get part of the filename from the selected item in another pane, and use it to compose the new list of filenames to rename files in the current pane:

Code: Select all

 $SelectedItem = get("Item", i);
 $ItemName = regexreplace("$SelectedItem", "(.*\\)(.*0530)(.*)(.....*)", "$2");
 //$List = listfolder(, , , <crlf>);
 //$List = formatlist($List, s, <crlf>);
 $List = report("{fullname}<crlf>",0);
 $P = "0";
 $RenamePreview = "";
 foreach($Item, $List, "<crlf>") {
 $RenamePreview .= $ItemName . _ . $P<crlf>;
 $P = $P+1;
 }
 rename l, $RenamePreview, p, $List;
The last separator becomes a path, see attachments. If I use replace() to replace it, I will get "Error 14, Out of string space" when the filename is long.
listfolder() gets a list with no separator at the end, but cannot get a manually sorted list.

Re: Script batch rename problem

Posted: 11 May 2022 14:43
by highend
As always, no clue what he wants...

Re: Script batch rename problem

Posted: 11 May 2022 15:01
by Horst
Yes, I also only understand 1 out of 10 of his posts :)

Re: Script batch rename problem

Posted: 11 May 2022 15:43
by Norn
I'm just reporting a problem and think the script is shorter...
Well, my poor English prevents me from explaining everything in detail.
Get part of the filename from the selected item in another pane, and use it to compose the new list of filenames to rename files in the current pane.

Re: Script batch rename problem

Posted: 13 May 2022 15:04
by Norn
+if $Item != "" {}
Not sure why I tried it before and it didn't work :oops:

Code: Select all

 $SelectedItem = get("Item", i);
 $ItemName = regexreplace("$SelectedItem", "(.*\\)(.*0530)(.*)(.....*)", "$2");
 $ItemExt = regexreplace("$SelectedItem", "(.*\\)(.*0530)(.*)(.....*)", "$4");
 //$List = listfolder(, , , <crlf>);
 //$List = formatlist($List, s, <crlf>);
 $List = report("{fullname}<crlf>",0);
 $P = "0";
 $RenamePreview = "";
 foreach($Item, $List, "<crlf>") {
 if $Item != "" {$RenamePreview .= $ItemName . _ . $P . $ItemExt<crlf>;}
 $P = $P+1;
 }
 rename l, $RenamePreview, p, $List;