Move everything prior to "-" to the end of file name

A swapping-ground for Regular Expression syntax

Move everything prior to "-" to the end of file name

Postby esumsea » Mon Jun 18, 2018 5:19 pm

Hello Everyone! I am new here. Trying to figure out how to use these scripts but not having much success. :oops:

So I come to you gurus for help. :D

I have a bunch of files in the format:
Angela Hewitt - Beethoven, Piano Sonatas Vol. 1 (2006) [SACD] {Hyperion}

I Would like to change it to:
Beethoven - Piano Sonatas Vol. 1 (2006) [SACD] {Hyperion} (Angela Hewitt)

There are also some that do not have the comma problem, so I would like a version of the script that would also deal with that. For example:
Duo Lechner Tiempo - La Belle Epoque (2009) [SACD] {Pure Music}
To
La Belle Epoque (2009) [SACD] {Pure Music} (Duo Lechner Tiempo)

Any help would be greatly appreciated!
esumsea
 
Posts: 4
Joined: Mon Jun 18, 2018 5:09 pm

Re: Move everything prior to "-" to the end of file name

Postby therube » Tue Jun 19, 2018 4:49 pm

Well, that sure wasn't easy, & don't know that I even understand the answer, but it looks like this will do it:

1:RegEx
Code: Select all
Match: ([\s\S]*?)(\s-\s)(.*)
Replace: \3 (\1)

The problem I ran into was if there were other hyphens in the word (like "Angela-Hewitt - Beethoven.*", otherwise it was relatively easy).
Pulled the idea from hlcs's post here,https://stackoverflow.com/questions/2404010/match-everything-except-for-specified-strings.


Oh, I didn't realize your comma issue in the first example.


Then also include...

3:Replace
Code: Select all
Replace: ,
With: <sp>-

That will replace all , with <sp>-.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions