How to Export an XML File in the Music App in macOS Catalina

iTunes was long able to create an XML file, which was a readable dump of its library file, so the apps could access information about your library. This file was also useful to have as a backup; if your iTunes Library file got corrupted, loading the XML file could allow you to recover your library.

In the macOS Catalina Music app, you can no longer have this file created automatically, but you can create it manually. This can be useful if you’re a DJ and want to use it with software that hasn’t been updated to use the iTunesLibrary framework, or if you just want to have a backup of your library.

To do this, choose File > Library > Export Library, name the file, and save it.

Xml file

Again, there’s no way to automate this, but if you do need the file to use with a DJ app, you can just dump it before your set.

Learn more about the new media apps that replace iTunes in macOS Catalina in my new book, Take Control of macOS Media Apps.

15 thoughts on “How to Export an XML File in the Music App in macOS Catalina

  1. Presumably this _could_ be automated with UI scripting? I’m not saying this is desirable, but surely possible?

      • Yeah, I saw there are no commands in the scripting dictionary, but UI scripting is a feature of AppleScript where you can describe the UI element you want to select (so you can specify a menu item to select). I’ve not used it much, but I think it could be used as a hack to automate something like this that’s not in the app’s scripting dictionary.

        • I know. Not something I’ve ever really used, however. It would require that the Music app be open and frontmost, right?

          • UI scripting is used in standard AppleScripts, so you could use a normal

            tell application “Music” to activate

            as the first line of the script, and then go into the UI scripting.

  2. It indeed is very sad how everyone is repeating each other without due dilligence.
    I posted this article on Redit the moment Catalina went public

    I contacted Dani and even provided her with a short video showing how this works

    Still the article has yet to be rectified, but I see it pop up all over the net.

  3. btw this can’t be AppleScripted (trust me it was the first thing I tried in the Beta).
    It can indeed be User Interface (UI) scripted (=recording mouse clicks/movements and key strokes), but that is too sensitive to user interference while the script is in progress, messing up the script’s execution. And it would be language dependent to store the XML at the to be expected location, something you don’t want.

    • Does it need to have a specific name and be in a specific location, or can you point these DJ apps to the file wherever it is?

      • it’s safest to keep it in the folder iTunes within the Music folder and name it iTunes Music Library.xml

        ~/Music/iTunes/iTunes Music Library.xml

        not all software allows for chosing a random stored XML. most have the above file path hardcoded

  4. I posted this script on the Slimdevices Forum. It may be of interest to someone here.

    This is not meant as a solution to the missing .xml file, I was just looking at what could be done in Catalina. The script is ugly, not very tested, sends keypresses to the Music application, and it will probably break unless used carefully. But it will attempt to tell the Music app to do a File – Library – Export Library… and put it in ~/Music/iTunes/iTunes Music Library.xml which is probably where applications expect to find it. So it is not production ready, but it appears to work. So I figured someone else might want to look at half automating the export of the xml file.

    You can open the script in Script Editor and export it as an Application to run it by double clicking on it. You will have to grant it access in Security Preferences of Catalina. With minor modifications it should be able to export specific playlists to xml. And you can of course do the same manually from the Music app on Catalina, which is safer.

    tell application “Music”
    end tell

    tell application “System Events”
    tell application process “Music”
    tell menu 1 of menu bar item “File” of menu bar 1
    click menu item “Export Library…” of menu 1 of menu item “Library”
    end tell
    repeat until exists window “Save”
    delay 0.1
    end repeat

    set musicfolderpath to get path to music folder
    set libraryxmlpath to POSIX path of musicfolderpath

    tell window “Save”
    keystroke “g” using {command down, shift down}
    repeat until exists sheet 1
    delay 0.1
    end repeat

    tell sheet 1
    keystroke libraryxmlpath
    keystroke “/iTunes”
    click button “Go”
    end tell
    tell window “Save”
    keystroke “iTunes Music Library.xml”
    end tell
    click button “Save”
    if sheet 1 exists then
    click button “Replace” of sheet 1
    end if
    end tell
    end tell
    end tell

  5. @roundjr I’m exactly where you are at in all of the above and have not found a better way to date. Your solution works at my end. I am also on a quest to address the “” directly without keystrokes.

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.