Page 1 of 1

Help with renaming files

Posted: 08 Apr 2016 18:20
by Skeeve
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

Re: Help with renaming files

Posted: 09 Apr 2016 01:12
by highend
Only possible via scripting

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);
    }

Re: Help with renaming files

Posted: 09 Apr 2016 12:58
by Skeeve
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!