How to move the text after the last hyphen to the front

Bulk Rename Utility How-To's

How to move the text after the last hyphen to the front

Postby holyroller » Tue Mar 17, 2020 9:43 pm

Hey guys, having a little trouble getting this one to work. I want to move the text that occurs after the last hyphen to the front, with a hyphen after it.

So from this: File-Name-Text-Set

To this: Set-File-Name-Text

I'm having trouble because each filename has multiple dashes in it. Any help would be much appreciated!
holyroller
 
Posts: 2
Joined: Tue Mar 17, 2020 9:35 pm

Re: How to move the text after the last hyphen to the front

Postby Admin » Tue Mar 17, 2020 11:22 pm

Can the file name have 1, 2, 3, 4, 5 etc dashes and the last part needs to be moved to the front?
Admin
Site Admin
 
Posts: 2344
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to move the text after the last hyphen to the front

Postby therube » Wed Mar 18, 2020 12:32 pm

This finds anything up to the last dash,
then anything after then last dash,
flips their positions & adds a dash back in between.


1:RegEx
Code: Select all
Match:  (.*)-(.*)
Replace:  \2-\1


Code: Select all
De Sandwich 20-10-2019.mp3                2019-De Sandwich 20-10.mp3
Benford, Gregory - Poveste razboi.epub    Poveste razboi-Benford, Gregory .epub
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to How-To