Page 1 of 1

Script or Reg expression to bracket numbers

Posted: 24 Dec 2011 07:23
by kluv
As the Subject says I'm looking for a script or regex that will allow me to bracket numbers while renaming files. All my .mp3 files names are Album, artist, track#, Track title. The problem is there is no dividers for me to use when separating. The Album name is simple since it is all the same character length but the artist (variable length), track number (1-2 char) and title (variable length) are the problem child.

ex. Tapes Top 20 Vol. 20 Ne-Yo 14 Can We Chill.mp3 to Tapes Top 20 Vol. 20 Ne-Yo [14] Can We Chill.mp3

Your help is greatly appreciated. Thank you.

Re: Script or Reg expression to bracket numbers

Posted: 24 Dec 2011 11:17
by highend
Why don't you use an mp3 tagging tool for that kind of task?

e.g.: MP3Tag

You can define actions to manipulate fields directly.

After defining the action you only need to select all files, execute the action,
hit Alt + 1, enter your destination format for the file name and you're done.

Re: Script or Reg expression to bracket numbers

Posted: 26 Dec 2011 14:01
by kluv
I've tried several of them, but because there's nothing separating the fields except the spaces there's no way to tell the program whether the title or artist is 1,2 or 3 words long. The whole reason I'm trying to get the brackets is to create separation between the fields then I can use MediaMonkey to take care of everything else.

If I try to define the fields in a MP3 tagger for: Tapes Top 20 Vol. 20 Ne-Yo 14 Can We Chill.mp3, I'd do <Album:20> <Artist> <Track#:2> <Title> , which probably still wouldn't work right but if the artist is 2 words then it throws it way off.

Re: Script or Reg expression to bracket numbers

Posted: 26 Dec 2011 16:43
by Stefan
kluv wrote:but because there's nothing separating the fields except the spaces there's no way to tell the program whether the title or artist is 1,2 or 3 words long.
If there is no common pattern in the file name to spot the tag nr. then you are out of luck
because you have to tell an script how to get the tag nr. part.

If you have ID3 tagged your files correctly you can try to rename the files after those tags.
See XYplorer menu "File > Rename Special > MP3"

Re: Script or Reg expression to bracket numbers

Posted: 26 Dec 2011 16:50
by Marco
Stefan wrote:
kluv wrote:but because there's nothing separating the fields except the spaces there's no way to tell the program whether the title or artist is 1,2 or 3 words long.
If there is no common pattern in the file name to spot the tag nr. then you are out of luck
because you have to tell an script how to get the tag nr. part.

If you have ID3 tagged your files correctly you can try to rename the files after those tags.
See XYplorer menu "File > Rename Special > MP3"
Exactly. The reverse (tag >> filename) is really easy and highly customizable with any "serious" tagging program (I use Mp3tag), but what you described above is impossible, since even album, artist and title could contain numbers.

Re: Script or Reg expression to bracket numbers

Posted: 27 Dec 2011 11:41
by kluv
Darn the luck. Thank you guys for taking your time to reply.

Re: Script or Reg expression to bracket numbers

Posted: 27 Dec 2011 14:56
by j_c_hallgren
kluv wrote:Darn the luck. Thank you guys for taking your time to reply.
While it's not automated, maybe using http://www.xyplorer.com/release_9.60.htm#edititemnames would make it a tad bit easier? As it says, if one copied the list to a text document, you could use the word processor's find/replace to locate and change/skip the desired separators?

Re: Script or Reg expression to bracket numbers

Posted: 27 Dec 2011 18:06
by avsfan
Is the track number always the last number in the name? if so, there should be a way to identify it using a regex (I'm not a scripting/regex person, but we certainly have some of them on here...)