renaming inside of dashes

A swapping-ground for Regular Expression syntax

renaming inside of dashes

Postby lcastan » Mon Jun 27, 2011 3:08 am

I have lots of files that are not named incorrectly. for example
SF263-01 - Kate Nash - Pumpkin Soup
Should be
SF263-01 - Nash, Kate - Pumpkin Soup

I tried copy and manipulate some examples in this forum but to no avail. could someone help?

Thanks.
lcastan
 
Posts: 4
Joined: Sat Jun 25, 2011 6:23 am

Re: rebnaming inside of dashes.

Postby Stefan » Mon Jun 27, 2011 2:50 pm

FROM:
SF263-01 - Kate Nash - Pumpkin Soup
TO:
SF263-01 - Nash, Kate - Pumpkin Soup


Shoot in the dark, just try it, hope it works....

We use an RegEx:
Match anything till space/hyphen/space but non-greedy ==> "(.+ - ?)" ==> "(SF263-01 - )" ==> Group 1
Match anything till an space ==> "(.+?) " ==> "(Kate) " ==> Group 2
Match anything till an space ==> "(.+?) " ==> "(Nash) " ==> Group 3
Match the rest ==> (- .+) ==> "(- Pumpkin Soup)" ==> Group 4

What is matched by the expression inside an (..)-group can be reused in the output by using "\1", "\2", "\3"... meta chars.
So just reorder the output as needed (by adding some blanks or comas as needed) ==> \1\3, \2 \4


I would try:
RegEx(1)
Search: "(.+ - ?)(.+?) (.+?) (- .+)"
Replace: "\1\3, \2 \4"






Note:
* test this first with copies of your real files!
* this solution will only work for names, build like the examples you have provided. Maybe you have to adjust the expression, add or remove an blank or like that.
* select a few or all files in "Name"-column to see the preview in "NewName"-column.
* if all went fine, press at [Rename]

HTH? :D
Last edited by Stefan on Tue Jun 28, 2011 4:30 pm, edited 1 time in total.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: rebnaming inside of dashes.

Postby lcastan » Mon Jun 27, 2011 5:00 pm

Stefan,

many thanks for your reply. I've tried what you proposed but it only works when the song name is composed of ONLY two words separated by a space.
When the song name is longer than two words it does not work.
That is:
SFPL007-11 - Sheena Easton - For Your Eyes Only.zip
when I apply what you proposed I get
SFPL007-11 - Sheena Easton - Your, For Eyes Only.zip

Otherwise it works as in the previous example.
lcastan
 
Posts: 4
Joined: Sat Jun 25, 2011 6:23 am

Re: rebnaming inside of dashes.

Postby Stefan » Mon Jun 27, 2011 9:25 pm

Right, silly me.

There is an "- " missed in the fourth part of the search expression. (See the example result behind?)

Try to fix it your own, so you get used to how it works. I will edit my post tomorrow.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions