Hi guys,
Very often I have to rename files with let's say kinda chaotic names into a more technical and organized format. The rename features of XY seem to be very flexible and versatile, but I still wasn't able to achieve the required results without manual edits.
Here are some examples:
Before -> After
Dungeon 8 New mastered finalized.wav -> Dungeon 008.wav
Battle special version 12 stereo upgraded FIXED.wav -> Battle 012.wav
Intro 1 Preview RAW.wav -> Intro 001.wav
I figured out how to grab the number with a regular expression, but wasn't able to achieve the result with the leading zeros. Is this possible at all? If so, how?
All help is much appreciated.
Thanks,
Kind regards
Help with renaming files
-
highend
- Posts: 14996
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help with renaming files
Only possible via scripting
E.g.:
E.g.:
Code: Select all
foreach($file, "<get SelectedItemsNames |>") {
$firstWord = gettoken($file, 1);
$number = format(gettoken(regexmatches(gpc($file, "base"), "\d+"), 1), "000");
renameitem($firstWord . " " . $number, $file);
}
One of my scripts helped you out? Please donate via Paypal
-
Skeeve
Re: Help with renaming files
Hi highend,
Many thanks for the script, that's extremely helpful. I should look deeper into the scripting system, seems to be very powerful.
Thanks again for your help, much appreciated!
Many thanks for the script, that's extremely helpful. I should look deeper into the scripting system, seems to be very powerful.
Thanks again for your help, much appreciated!
XYplorer Beta Club