Page 1 of 1

Rename file by transposing text

Posted: 29 Mar 2016 18:20
by Turion
Hello, I have some files that are named like

Code: Select all

A Video File-01.mp4
Another, A Video File-105.mp4
Yet Another, A Video File-568941.mp4
I want to transpose or swap the text part with the number part so it'll look like

Code: Select all

01 A Video File.mp4
105 Another, A Video File.mp4
568941 Yet Another, A Video File.mp4
The dash "-" isn't important. What's the easiest way of doing this?

Re: Rename file by transposing text

Posted: 29 Mar 2016 18:48
by highend
You can use the context menu on these files with:
Rename Special - RegExp Rename...
and this pattern:

Code: Select all

^(.*)-(\d+) > $2 $1
Note:
Configuration | Menus, Mouse, Safety | Context Menus | File List...
[x] Rename Special
must be checked!


or you select your files and execute this script:

Code: Select all

    foreach($file, "<get SelectedItemsNames |>") {
        renameitem(regexreplace(gpc($file, "base"), "^(.*)-(\d+)$", "$2 $1"), $file);
    }

Re: Rename file by transposing text

Posted: 30 Mar 2016 04:13
by Turion
Thank you! Works perfectly :)