swap all between space-space

A swapping-ground for Regular Expression syntax

swap all between space-space

Postby rlatreille » Tue May 22, 2012 2:24 am

Hi
I'm trying to swap song title and artist name.
they are separated by a space a dash and a space.
There are sometimes dashes in the song titles but not between spaces.

ex:
1-2-3 - GLORIA ESTEFAN.mp3
(shake shake skake) your booty - KC & The Sunshine Band.mp3

Thanks for your help

Robert
rlatreille
 
Posts: 2
Joined: Tue May 22, 2012 1:46 am

Swap between space dash space Song - Artist

Postby Stefan » Tue May 22, 2012 9:52 pm

Swap around "Space-Dash-Space"

e.g.

FROM:
Title - Artist.ext
Song - Artist.ext
Given-name - surname

TO:
Artist - Title.ext
Artist - Song.ext
surname - Given-name

Rule:
There is only exactly ONE pattern " - " in the file name!
(if you have more then one of this pattern, you have to do other things, like temporary replace
one pattern with an un-common sign, or modify the RegEx )

Do:
* test this solution first with COPIES of your real files!
* select a few or all files in "Name"-column to see the preview in "NewName"-column.
* if all went fine, press at [Rename]

USE:
RegEx(1)
Search: (.+)( - )(.+)
Replac: \3\2\1
[ ] Include Ext. un-checked



Explanation:
* Note: this RegEx will only work as expected on files like the above examples.
(.+)( - )(.+) ===> match: (one-or-more of any sign) till (space dash space) followed by (one-or-more of any sign)
\3\2\1 =======> replace with what is matched inside third (...), then second (...), then first (...)

Read more:
- read the help about regular expression
- search the forum for more of this examples
- read the sticky top post of this RegEx-Forum: "Getting help with Regular Expressions
- read the two very first posts of this RegEx-Forum (at the last page now):
- - - Getting Started - Overview over the RegEx syntax (Regular expressions, regexes. RegExp, RE)
- - - Go ahead - Some interesting sides about reg ex,


HTH?
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: swap all between space-space

Postby rlatreille » Tue May 22, 2012 10:45 pm

Works great

Thanks a million

Robert
rlatreille
 
Posts: 2
Joined: Tue May 22, 2012 1:46 am

Re: swap all between space-space

Postby Alicia » Tue Oct 09, 2012 9:29 pm

I've been trying for hours to get this to work, until I found your explanation. Thank you so much! It's very detailed and easy to understand. :)
Alicia
 
Posts: 1
Joined: Tue Oct 09, 2012 9:14 pm

Re: swap all between space-space

Postby Stefan » Tue Oct 09, 2012 9:52 pm

Thanks for the feedbacks! (Not many do that)
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: swap all between space-space

Postby elfangor67 » Tue Aug 19, 2014 3:14 pm

I still don't understand the instructions, and the program still confuses me. I have files I'm trying to rename, but I can't figure it out. I'm trying to rename files from "Catagory# - Song - Artist.ext" to "Catagory# - Artist - Song.ext". Could someone provide step-by-step instructions please?
elfangor67
 
Posts: 2
Joined: Tue Aug 19, 2014 3:01 pm

Re: swap all between space-space

Postby elfangor67 » Tue Aug 19, 2014 5:55 pm

elfangor67 wrote:I still don't understand the instructions, and the program still confuses me. I have files I'm trying to rename, but I can't figure it out. I'm trying to rename files from "Catagory# - Song - Artist.ext" to "Catagory# - Artist - Song.ext". Could someone provide step-by-step instructions please?


Never mind, I figured it out I did it like this:

FROM:
Catagory# - Song - Artist.ext

TO:
Catagory# - Artist - Song.ext

USE:
RegEx(1)
Search: (.*) - (.*) - (.*)
Replace: \1 - \3 - \2
[ ] Include Ext. un-checked
elfangor67
 
Posts: 2
Joined: Tue Aug 19, 2014 3:01 pm

Re: swap all between space-space

Postby Stefan » Tue Aug 19, 2014 6:28 pm

Bravo!
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions


cron