dougscripts.com

June 4 2014 - 1:39 pm

NEW: Track CPR

iTunes will let you re-associate a file with a single selected dead track.

This really is the safest way for iTunes to do this. The user approves a one-to-one correspondence with a user-selected track and a user-chosen file. If an error choosing the correct track/file pair is made, the user made it, not iTunes. Still, being able to point an album's or artist's worth of dead tracks at a folder of corresponding files seems like it would be a simple task, though in practice perhaps not always one-hundred percent fool-proof.

I've been putting off building something like that for a long time because of the fool-proof factor. It's restrictive and awkward to make a one-size-fits-all tool without including a lot of options to account for idiosyncratic ambiguities that ultimately may generate more support issues—to put it politely—than I would like to handle.

With compromise and limitations in mind, I'm posting Track CPR, a script that assists with batch re-associating files with dead tracks.

And, in the interest of avoiding as many support issues as possible it's somewhat narrowly focused; while this script will do a lot of the work for you, it can't make a lot of decisions for you. Therefore you may find it tedious.

But not as tedious as clicking the "Locate" button 200 times:

So here's how it works:

  • It finds and lists all the dead tracks in your library.
  • You select a batch of those dead tracks and then select a folder which the script will search recursively for files with filenames that are the same as the filenames belonging to the missing files of the dead tracks you have selected.
  • You decide that the files the script has found are viable replacements for the missing files of the selected tracks. Then have the script make it so.

And this is the narrowly focused part:

1) There must only be one file in the selected folder—at any level—that has the exact same filename as a particular dead track. Any folder of replacement files that you select must contain only one file whose filename is the same as one of the operative dead tracks in order to be considered as the single viable replacement for that track.

(Otherwise selecting any arbitrary folder of files is more than likely to produce undesirable results. Even if one user says "I'm sure these are the correct files even though they aren't named the same", I can't write a script that will prevent another user from having a nervous breakdown because the script replaced the wrong files in the wrong order. See point number 3 below and support issues comment above.)

If necessary, manually change the file names in the Finder in order for the script to accept them as viable replacement files.

Additionally, If you are looking to replace all your Rolling Stones albums in one go (not advisable) and there are seven versions of "Gimme Shelter.m4a" in seven different Album sub-folders then none of them will be considered. Select a folder as close as possible to a single potential replacement file to avoid finding more than one same-named file. Attempting CPR on an album's worth of tracks with one folder's worth of files may be ideal.

2) Replacement files will remain in their current location; so unless they are already in the "iTunes Media" folder they will not be moved there after replacment. It is tricky to programmatically deduce if the iTunes Preference "Copy files to iTunes Media folder when adding to library" is set. And, technically, the replacement operation this script performs is not "adding" a file to iTunes; it is replacing the text value for the Location key of a track entry that is already in the iTunes database. A script could re-add the file, attempt to copy over all the tag data from the original track, delete the original file, and so on. But this script won't, because there's about a million ways any of those operations could be screwed up by some unanticipated problem. (Take it from me. I've been doing this for fourteen years. Support issues.)

If necessary, manually move potential replacement files to their final resting place first, then use the script.

3) The replacement operation cannot be undone with the script.

If you can live with those parameters then you shouldn't have a problem using this assistive tool.

More information and download is here.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.