How to rebuild the Music app's index

“Something” romped all over my Music library, and left it in a mess. I have restored my media folder (on an external drive). But Music just messes it all up again every time I restart it.

What files do I have to delete to just do a clean start? (iCloud is not involved. All music is on the one external drive.)

Thanks all.

Like Photos, you can option-click on the Music icon and it should prompt you to choose a library or create a new library - you’d obviously do the latter in this case. I think music (and photos) remembers the choice for subsequent regular launches of the music app.

I’m not sure what you mean by something leaving your library “in a mess,” but you might take a look at the Files tab in your Music Preferences and check to see if “Keep Music Media folder organized” and “Copy files to Music Media folder when adding to library” are checked to behave as you expect.

I did recently run into a situation where Apple Music replaced correct artwork on quite a few songs with entirely unrelated artwork, e.g., wrong song, wrong artist, even though I long have had “Automatically update artwork” disabled. I presume it is somehow related to Apple iTunes Match. Apple Music truly is unreliable for people who wish to curate and maintain their own music collections rather than rely on music streaming services.

Tried all that, but thanks. “in a mess” is recreating the parent directory inside itself but only partially, some artists, some albums, some tracks, left place in the parent, literally scrambled. It actually moves the *.library files.

Thanks to CCC, I can restore that, but then Music just trashes it again. I really do need to get rid of all Music’s configuration files, and set up Music from scratch.

Only have a guess how this happened.

You can, as a last resort, delete your library altogether (but don’t delete the media folders that hold your actual music files). Then create a new library (via an option-launch of the app) and drag/drop your files into the running app to import them all to the new library.

This will trash all your playlists and maybe some metadata, so I consider it a last resort, but it will work.

1 Like

Last resort is definitely where I am at, but deleting “Music Library.musiclibrary” wasn’t enough. I’m just going to have delete anything suspicious (and, I guess, restore what breaks it worse… :-}

Thanks.

Out of curiosity, what is the location of your music library in your Music preferences?

For example, mine is:

/Macintosh HD/Users/(myusername)/Music/iTunes/iTunes Music

If you’re up for it, one more thing you could try is to create a new user account, import your music, copy the Music configuration files, then replace the damaged configuration files in your existing user account.

1 Like

The location of the music database should be arbitrary. And you can have multiple libraries - the app will use the last-opened library, the one you double-clicked (if you launched Music that way) or will let you pick one (if you option-launch Music).

FWIW, my Music library is ~/Music/Music/Music Library.musiclibrary

But that library may reference media files in any location. With Music running, go to Settings → Files and you can see the media folder location. In my case, it’s a location inherited from iTunes: ~/Music/iTunes/iTunes Music:

When you purchase music via the iTunes Store or when ripping CDs, the files are placed in that media folder.

If you drag/drop music files to your library they will be copied to the media folder location if the “Copy files to Music Media folder when adding to library” box is checked. If not, then the files will be left where they are and the library will simply add a reference to the file’s original location (meaning that if you delete that file or move it to another storage volume, the Music library will not be able to find it).

The “Keep Music Media folder organized” checkbox may be used to tell Music to organize the files in a particular pattern within that media folder (artist/album/track, with the tracks named with disc and track numbers so they sort in the album’s play sequence).

If you have files in your library that are not in your Media folder, and/or if you want to reorganize them according to the “Keep organized” algorithm you can select File → Library → Organize Library…, check the appropriate boxes and click OK:

Screenshot 2024-11-25 at 16.01.35

The Consolidate option will copy any files not already in the media folder to that folder. The Reorganize option will move files in the Media folder so they fit the above schema.

BTW, this is a good way to move your media to another location without breaking anything. Create a folder for the new location, change the media folder, then consolidate your library. Everything will be copied to the new media folder. Once that finishes, you can delete the old media folder.

1 Like

You should not have more than one Music Library.musiclibrary file. Use Spotlight to be sure you find and delete all of them.

If there is a top level folder that contains all your music files, you can stop Music.app from moving any of the music files by turning OFF the two checkboxes “Keep Music Media folder organized” and “Copy files to Music Media folder when adding to library”.

I suggest this sequence:

  1. Turn off these two checkboxes.
  2. Quit Music.app.
  3. Delete all copies of Music Library.musiclibrary.
  4. Launch Music.app.
  5. In Music > Settings > Files, verify that the two checkboxes remain off. Click the “Change” button, then select the top level folder that contains all your music files. Music.app then will rebuild the Music Library.musiclibrary database in its default location in your user Music folder, not in the top level music files folder you just selected.

Thanks for all the suggestions. I think I’ve got it sorted (more or less). My original setup dated wayback to early iTunes, and most of the pref files still referenced it. I just trashed it all and started fresh. Not sure it is ever going to work quite the same, but close enough.

There are some tips from a couple of years ago here:
https://discussions.apple.com/thread/254405647?sortBy=rank

In brief, the poster used Show Package Contents for the library file and deleted some temporary files.

1 Like