mp3 script revisited

lethe

Registered
I want to write a script for merging mp3 collections. i have 2 large mp3 collections on my computer, one is mine, the other i got from my brother. i started writing it in bourne a while ago, but was unable to get it to accommodate spaces in filenames. with a recent thread from shatfield and input from testuser, now i know how to deal with that issue.

i was thinking of doing it in perl (which i don t know very well) or applescript. i want to know what you think the best choice for this is.

my goals for the script are these:

1. it should be able to recurse down directory trees.

2. it should be intelligent about duplicates. if there is a duplicate, it should choose one with a better bit rate. or bigger filesize.

3. it should be smart about filenames. some files look like "artist - trackname" while others are just "trackname" contained in album directory, in artist directory.

4. it would be nice, but not imperative, if it could use ID3 tags for decisions as well. for this, i believe the easiest way would be to use applescript, and ask iTunes for tags.

any input will be appreciated.
 
This is perl module which you can use to check and set the ID3 info of an mp3. You can find it here.
http://sourceforge.net/projects/mp3-info/

I don't do much perl so I can't help you that much. But i think that you would have more luck with perl. I think it is much more powerful and robust than applescript. I don't know how good you are at applescript though, but I think you'll find its easier to get help with perl than it is to find help using applescript. The perl community is bigger than applescript. Perl has excellent support for regular expressions which you will need if you wish to be smart about the filenames. Even though i think that might be tough, because all different people seem to use different naming connections. I would first check the id3 tags for all artist and song information, as I'm sure that is the most reliable source of it. Perl also has access to the file system, so you can walk the tree structure of it as you need too.

As for your duplicates, your going to have to maintain a list of your mp3's somewhere, but unless you want it to slow as all hell, your going to need to keep it in some kind of structure, that is quickly searched. (can you imagine searching your list of 10,000 mp3's linearly every time you want to add a file). I'm sure perl has some data structures to use that will help you out on that account. good luck
 
I would dump all of the mp3s into iTunes 3 and let it sort them out by Artist->Album->Song.mp3. Then I would write a php script to go through your music folder and compare the files within each album folder using the levenshtein function on the file names. When iTunes 3 has duplicate songs it numbers them:
Song.mp3
Song 1.mp3

This is all assuming that your ID3 tags are pretty clean. The cleaner the tags are, the less fancy your script will have to be.

It would be simple to compare the two and keep the one that has a larger file size.

If you wanted to get real fancy, I'm sure someone out there has written a module for php that will parse ID3 tags.
 
Back
Top