Simple (Non-Looping, Intrinsic) Rename

Discuss and share scripts and script files...
Post Reply
MediaManny
Posts: 4
Joined: 24 Jun 2021 10:57

Simple (Non-Looping, Intrinsic) Rename

Post by MediaManny »

I feel like a complete idiot. I've wasted two hours experimenting with different techniques to rename files by script.

All of the examples on the forum appear to use loops, which I don't think is required in this instance -- and yet I just can't find a solution.

I'm forced to do this in a script because I need to execute over 100k+ files. Because XYplorer doesn't allow selecting a folder and recursively renaming below this, I would have to select all files -- which essentially times-out/locks-up due to the large number of files.

I thought I could do something simple, like:

Code: Select all

$files = <get SelectedItemsPathNames>;
rename r, "\W*(remove1|remove2|remove3)\W* > ", $files;
(to make it easier to understand, I've altered regex to be very simple/straightforward)

I'd just like to drop a folder on my .xys script and have it apply a Regex rename across all files recursively below that folder.

Is my belief wrong; is this not something that can be done in two lines without looping?

Thank you in advance!

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

Re: Simple (Non-Looping, Intrinsic) Rename

Post by highend »

Ofc this can be done without looping. But not without getting all the files to be renamed^^

Code: Select all

rename "r", "(\W*(?:remove1|remove2|remove3)\W*) > ", , quicksearch("/f", <get drop>, , "s");
One of my scripts helped you out? Please donate via Paypal

MediaManny
Posts: 4
Joined: 24 Jun 2021 10:57

Re: Simple (Non-Looping, Intrinsic) Rename

Post by MediaManny »

highend wrote: 22 Mar 2022 09:32 Ofc this can be done without looping. But not without getting all the files to be renamed^^
Thank you, that's very helpful.

As explained in the original post, the need to use a script is due to there being far too many images to be able to select them all. It brings XYplorer to a crawl.

I thought I might be able to modify your quicksearch example to do what I needed. Unfortunately, the quicksearch() topic in the help-file does not mention either the "/f" or "s" params -- and I'm not sure what they do or whether there is a route where modification would enable my intended goal.

Thank you again for the insight.

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

Re: Simple (Non-Looping, Intrinsic) Rename

Post by highend »

I'd just like to drop a folder on my .xys script and have it apply a Regex rename across all files recursively below that folder
That's exactly what my script line does...
Unfortunately, the quicksearch() topic in the help-file does not mention either the "/f" or "s" params
1.
1.png
1.png (10.71 KiB) Viewed 1254 times
2. Ofc it's not shown a second time inside the function explanation.If you would have followed the link to Quick Search you'd have seen all the available switches...
2.png
2.png (8.62 KiB) Viewed 1254 times
Animation.gif
Animation.gif (460.65 KiB) Viewed 1250 times
One of my scripts helped you out? Please donate via Paypal

Post Reply