MP3 Filename

Advanced Renamer forum
#1 : 15/05-15 20:56
Jose Guerrero
Jose Guerrero
Posts: 3
Good day to whomever reads this. I have many MP3 files that have the artist name swapped with a comma seperating them I.E.

Beatles, The - Yellow Submarine
Aguilera, Christina - Moulin Rouge

Is there a method to swap just the Artist name to show

The Beatles - Yellow Submarine
Christina Aguilera - Moulin Rouge

and keep this for all my different MP3 files? Thank you in advance for your help.


15/05-15 20:56 - edited 15/05-15 20:58
#2 : 17/05-15 13:54
Tester123
Tester123
Posts: 92
Reply to #1:
Hi,

If your MP3 files don't contain the metadata (or the metadata is not in the same format), then the following technique will work directly on the filenames.

Assuming your filenames are in the format 'LastName, FirstName - Song Title.mp3', then you can use this replace method:

Text to be replaced: (.+)(, )(.+)( - .+)
Replace with: \3 \1\4
Case sensitive: Untick
Use regular expressions: Tick
Apply to: Name

To explain:

A little summary of the notation first.
The '.' (dot) means any character.
The '+' (plus) is a quantifier, and means one or more (i.e. at least one).
The '()' parentheses is a 'group' (as in the normal sense of the word and is useful in replacements)
The '\#' (e.g. \1 is used to refer to a previously defined group, in this case the first group).

The 'Text to be replaced', i.e. (.+)(, )(.+)( - .+) breaks down the filename into 4 groups. The first group means find at least one of any character (this represents the 'LastName' section in the filename format at the top), but stop when it finds a comma followed by a space (that's the second group). The third group is the same as the first group, but his time it represents the 'FirstName' part of the filename. The fourth group is the literal space-hyphen-space combination followed by any character(s) to denote the '- Song Title' part.

Now that the parts have been grouped, we can play around with them, including swapping them around to give us what we want.

So in the 'Replace with: \3 \1\4' expression, this means take group 3 which is the 'FirstName' part. Then add a space (literally) followed by the group 1, which is the 'LastName' part. Finally take group 4 which is the '- Song Title' part of the filename.

Notice that we defined group 2 to be ', ' but did not use it in the replace expression. That's one trick to get rid of unwanted sections. Group it in the search section but don't use it in the replace section.

Hope that does the trick!


17/05-15 13:54 - edited 17/05-15 14:11
#3 : 18/05-15 17:46
Jose Guerrero
Jose Guerrero
Posts: 3
Reply to #2:
You are a life saver. Thank you very much for your help!


18/05-15 17:46