<Solved>Script batch rename problem

Things you’d like to miss in the future...
Post Reply
Norn
Posts: 416
Joined: 24 Oct 2021 16:10

<Solved>Script batch rename problem

Post 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.
Attachments
Rename List.png
Rename List.png (39.45 KiB) Viewed 989 times
Last edited by Norn on 14 May 2022 16:41, edited 4 times in total.
Win10, Win11 @100% 2560x1440 22H2

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Script batch rename problem

Post by highend »

As always, no clue what he wants...
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Script batch rename problem

Post by Horst »

Yes, I also only understand 1 out of 10 of his posts :)
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

Norn
Posts: 416
Joined: 24 Oct 2021 16:10

Re: Script batch rename problem

Post 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.
Win10, Win11 @100% 2560x1440 22H2

Norn
Posts: 416
Joined: 24 Oct 2021 16:10

Re: Script batch rename problem

Post 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;
Win10, Win11 @100% 2560x1440 22H2

Post Reply