Apple - How to replace an MP3 or M4A in iTunes with a higher quality file, without having to re-do playlists containing the track?

You can just replace the file in the filesystem.

Unfortunately, iTunes is too clever for it's own boots and registers for Finder events. So renaming a file in Finder will update it's location in iTunes if iTunes is open!

So here's one way I've tried that works.

  1. Quit iTunes (actually quit, not just close window);
  2. Locate the file in Finder:
    • This could be done in iTunes (before quitting) by right-clicking and choosing Show in Finder;
  3. Replace the file in Finder with one with the exact same filename;
  4. Open iTunes

iTunes will then use this file when you attempt to play it. Note: if any of the ID3 tags differ they will be updated in iTunes too (which is probably what you want). This means if you replace it with a file with the same file name but with less information in the metadata, you'll have less information in the iTunes browser.


I wrote a python tool named replica that automates the task of replacing file while keeping id3 infos of the old file. pip install replica to install.
My use case is that I often download upgraded versions (bitratewise) of my favourites mp3 albums and am particularly interested to keep my ratings (that i duplicate in the grouping tag).

Usage :

If you replicate full albums, please make sure that tracks filenames are similarly ordered in both source and destination folders.::

$ replica -u Library/Sam_Cooke-Ain_t_that_good_news-128kbps-2003
Incoming/sam_cook-good-news-320kbps   
Cloning id3 metadata... Done  
Renaming files......... Done

In addition to id3 cloning, replica can handle files renaming too so that upgrading mp3 files becomes a no-brainer.
Consider the -u option to remove the source files and replace them by their upgraded version. Preserving filepaths enables you to migrate id3 metatags to new files while keeping the information stored by your music player (such as ratings or play counts) valid.


Upgrading iTunes files to higher quality without losing metadata

Turn off iTunes Match.

Rip higher quality version to iTunes.

Go to higher quality file. Right click - Show in Finder

Go to file to be replaced. Right click - Show in Finder

Quit iTunes

In Finder delete lower quality file - move to trash - empty trash

Drag higher quality file to where lower quality one was

Open iTunes - play track from location of old file

Song could not be found - locate

Repeat

Now you have duplicate images in iTunes. To delete these you need to follow these next steps.

Highlight all the redundant tracks in iTunes. Delete. Delete Songs. Keep Files.

Turn on iTunes Match.

Bingo.