<Solved>Script batch rename problem

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

: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: Use Your Profile Or Signature
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: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
Norn
Posts: 521
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: 15016
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: 1419
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 26H2 (OS Build 26300.9974)
Portable x64 XYplorer (Actual version, including betas)
Display settings 1920 x 1080 Scale 100%
Everything 1.5.0.1424b (x64), Everything Toolbar 3.5, Listary Pro 7.1.0.47 beta

Norn
Posts: 521
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: 521
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