<Solved>Script batch rename problem

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
Norn
Posts: 508
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.
To see the attached files, you need to log into the forum.
Last edited by Norn on 14 May 2022 16:41, edited 4 times in total.
Windows 11 24H2 @100% 2560x1440

highend
Posts: 14992
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 1400
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, Version 25H2 (OS Build 26200.9278)
Portable x64 XYplorer (Actual version, including betas)
Display settings 1920 x 1080 Scale 100%
Everything 1.5.0.1423b (x64), Everything Toolbar 3.2, Listary Pro 7.0.0.9 beta

Norn
Posts: 508
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.
Windows 11 24H2 @100% 2560x1440

Norn
Posts: 508
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;
Windows 11 24H2 @100% 2560x1440

Post Reply