Move iTunes Directories

This is probably not too helpful, since macOS Catalina has broken iTunes into an app for every media type, so the details of this post are mostly outdated if you've updated to Catalina. But I still have pre-Catalina (Mojave) on my MacBook Pro, and recently I searched and searched for an easy way to move my iTunes directory and couldn't find it.

To clarify what I mean when I say "move my iTunes directory": I don't allow iTunes to "Organize" my iTunes library. I choose where the files are located and how they are named and organized. There are lots of articles (including official Apple documentation) that explain how to move the iTunes-managed library directory. But none of those tutorials explain how to move your files from one directory to another when you're managing that location yourself.

This is a three-step process.

Step 1: Copy the files

The easy way to copy the files is using the macOS Finder, but if you have thousands of files this could be slow, as Finder seems to do a bunch of calculation up front so it can do fancy stuff like show progress bars. I'd prefer to do this quickly, so I wrote this bash script to safely copy my Music directory, subdirectory by subdirectory.

Script output

Step 2: Update iTunes track locations

This is the more challenging part, because your iTunes library is stored in a database file that isn't editable with external tools. A common work-around that is recommended is to export your iTunes library as XML and edit the XML, then re-import that edited XML as your new library. I've done that before, and found that it's very error-prone and leaves a lot of manual cleanup remaining.

So, I wrote an AppleScript to go through every track in your iTunes library and change its location from the old directory to the new directory.

On my iTunes library of about 10,000 tracks, it took quite a while to churn through everything: I didn't time it, but it felt like about 30 minutes. Maybe it was less.

Step 3: Remove the old files

After you're sure everything has been copied correctly and your iTunes library is correctly updated, you can remove the old copy of your files.