Script or Reg expression to bracket numbers

Discuss and share scripts and script files...
Post Reply
kluv
Posts: 35
Joined: 02 Mar 2011 13:23

Script or Reg expression to bracket numbers

Post 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.

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script or Reg expression to bracket numbers

Post 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.
One of my scripts helped you out? Please donate via Paypal

kluv
Posts: 35
Joined: 02 Mar 2011 13:23

Re: Script or Reg expression to bracket numbers

Post 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.

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Script or Reg expression to bracket numbers

Post 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"

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: Script or Reg expression to bracket numbers

Post 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.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

kluv
Posts: 35
Joined: 02 Mar 2011 13:23

Re: Script or Reg expression to bracket numbers

Post by kluv »

Darn the luck. Thank you guys for taking your time to reply.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Script or Reg expression to bracket numbers

Post 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?
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

avsfan
Posts: 554
Joined: 29 Jun 2006 09:00
Location: Fort Collins, Colorado

Re: Script or Reg expression to bracket numbers

Post 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...)

Post Reply