Rename file by transposing text

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Turion
Posts: 30
Joined: 01 Jun 2012 20:46

Rename file by transposing text

Post 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?

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

Re: Rename file by transposing text

Post 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);
    }
One of my scripts helped you out? Please donate via Paypal

Turion
Posts: 30
Joined: 01 Jun 2012 20:46

Re: Rename file by transposing text

Post by Turion »

Thank you! Works perfectly :)

Post Reply