0

I like to keep my iTunes library organised and all files well-tagged, so I often spend enjoyable yet unreasonably long amounts of time editing all the ID3 tags manually. Call it OCD or perfectionism, that's how I roll. Thankfully, iTunes is rather convenient for basic operations like batch-changing tags or artworks, but it only goes so far. The problem is that for much music I get, the tags have to be edited for each track individually, taking into account details like numbers and such. Here's an example of what I mean:

Track names and numbers need individual formatting

Notice that files have no embedded track numbers, and are numbered within the track name instead. This picture is more to my liking:

Manually renamed and retagged tracks

To achieve this within bare iTunes, one would have to input track numbers by hand and then remove the ХХ - from each name. Now, I can of course do this by repeatedly mashing the favoured combo (holding : Left Mouse Button), but when I need it for 300 tracks across numerous albums, this turns into a problem.

So I want to have a quick way for my Mac to do this for me. I imagine something like a script that extracts track numbers from file names or name tags through use of wildcard characters and applies them to respective ID3 tags while removing numbers from names. Finder has a handy built-in dialog for batch-renaming, but as far as I know it doesn't have this specific formatting functionality. I tried Automator and MusicBrainz Picard, but they don't have that either.

Is there anything that can be of help? Script libraries for Automator or Terminal commands? Maybe some handy AppleScript functions I don't know of?

2 Answers 2

1

A Combination of AppleScript (or Shell Scripting if you are so inclined), along with a command line tool like id3v2 should do the trick.

You can build id3v2 from source: http://id3v2.sourceforge.net Or use MacPorts or HomeBrew to do the building and installation for you.

Once you have it installed you can view the help page by typing in "id3v2 ah" from the terminal. The help page is more helpful than the man page is.

Then it is just a matter of writing the AppleScript to pass the filenames into variables and use those variables on the command line script like such:

set shellScript to ("id3v2 -T " & trackNumber & space & numberofTracks & space & "/path/to/file") as string
do shell script shellScript

You may also want to think about changing the name of the file itself so that it no longer has the track number in the name!

I hope this can get you started!

6
  • No need to coerce your expression in the first line to a string. The fact that the first component is a text object necessitates the concatenated product to be of the same type class.
    – CJK
    May 22, 2019 at 19:30
  • I always set up my shell scripts into a string before I call them. That way if I need to I can just copy the variable data straight from Script Debugger and paste it into terminal to make sure it is doing what it is supposed to be doing. If you are just using Script Editor then the string coercion is indeed unnecessary. May 22, 2019 at 19:37
  • I use Script Debugger and I don't see how this affects anything. The variable data is a text (string) object with or without coercion.
    – CJK
    May 22, 2019 at 19:42
  • On a separate note, is a command line tool like id3v2 actually necessary ? iTunes is scriptable with AppleScript and it was my understanding that the AppleScript properties of each track collectively represent the the ID3 tag information, which are almost all gettable and settable. Or do I have this wrong ?
    – CJK
    May 22, 2019 at 19:47
  • I guess it depends on the properties that you want to set, and if you want those tags to be strictly iTunes compatible, or id3v2 compatible. The OP did ask specifically about ID3 tags, so that is why I went with the ID3V2 command line utility. Looking at the "Declared Frames" of ID3v2 and the properties that iTunes exposes to AppleScript, there are 74 different ID3V2 frames but only 68 Properties in iTunes and the two lists look fairly different. May 22, 2019 at 19:59
0

I have used Kid3 for years and recommend it:

https://kid3.kde.org/

I mostly use it album by album but it does have some programmatic capabilities as well.

I've since switched from Mac and am using MP3Tag on Windows which I like a lot better than Kid3. I think a dedicated MP3 tagging tool is the way to go.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .