Batch Relinking of Missing iTunes files?

I house a library of around 40000 songs. One of the things that I regret not doing when I started my digital collection 5 years ago is proper naming of the files and the folders itself, rather than only focusing on the ID3 tags. So, I have properly tagged files which have a poor and inconsistent naming system along with a messed up folder hierarchy. Some of my files are in subfolders (Especially when it comes to discographies), while others are in the parent folder. I'll be renaming the whole thing using Mp3Tag and also have a script for the cause. But, the next issue is that iTunes won't be able to detect my files after a massive change in the file and folder renaming.

The naming would be like this and all the albums would be on the same folder. No subfolders would be created except for Disc numbers in multidisc albums -

Album Artist (or Artist) - Album - Year - Bitrate (Folders)

Track number - Track name (Files)

I've tried this script over here http://samsoft.org.uk/iTunes/FindTracks.vbs but it failed to recognize the files on a smaller portion of files that I had tested. Is there an alternate solution. I don't want to lose my ratings, play counts and playlists. I won't bother much about date and time tags, though. I'd like to emphasize that the ID3 tags would remain exactly the same, if that counts as a way to find back the links.

I'm using a Windows PC, so Applescripts would do me no favor, either. Thanks.

Posted on Apr 14, 2018 7:14 AM

Reply

Similar questions

13 replies

Apr 14, 2018 7:44 AM in response to arg274

Rather than break the existing link, moving files to something very different from the standard iTunes layout, and then try to fix it afterwards, it would be better to let a script manage the moving/renaming and relinking all in one go. See CustomRenamer for such a script. At the moment the following properties are available for use as part of the folder or file names, but they could be easily expanded:


<Album>,<AlbumArtist>,<Artist>,<Composer>,<DiscNumber>,<Genre>,<Grouping>,<Name> ,<TrackNumber>,<Year>


tt2

Apr 14, 2018 9:57 AM in response to arg274

The usual approach to disc numbers is not to include them at all unless the disc count is greater than one, in which case you include them for all discs. In terms of keeping things elegant on the drive you can either add the disc numbers before the track number, e.g.
2-13 - <Name>.<Ext>, or you can add an extra layer of folders. e.g. ...\Disc 2\13 - <Name>.<Ext>. I would normally go with the first option if I didn't already make a point of making my track numbers sequential over the whole album so that tracks are always at the same level regardless of other properties. I guess I could find a way to support the alternatives. Again without going over the script with this version you either include the disk number or you don't and you could chose to use different patterns for different selections of content.


I cannot see any obvious way to tell VBR from CBR in the scripting interface. You could potentially sort things into different playlists and then apply a different pattern to each.


One other side effect of the script it that moves any artwork when the last media file is moved out of an old folder, and then deletes any folders that become empty.


For now you could try testing with the pattern:

X:\Music\<AlbumArtist> - <Album> - <Year>\<TrackNumber> - <Name>

or

X:\Music\<AlbumArtist> - <Album> - <Year>\Disc <DiscNumber>\<TrackNumber> - <Name>


The file extension is included automatically. You could insert a - VBR or - CBR into those patterns as fits the selected content if you wish.


tt2

May 21, 2018 12:25 PM in response to arg274

OK, I've uploaded a new version of the script that suppresses the following items from the filepath:

  • Disc 0\
  • Disc 1\, only for an album with a disc count of 1
  • 00 - , space after -
  • 00-
  • 00 , space after 00


Each of the lines that make these changes can be commented out if you don't one of want them.


You can edit what is currently line 155 and starts Pattern= putting your preferred pattern in between the quotes so you don't have to type it out each time.


tt2

May 21, 2018 3:45 PM in response to turingtest2

So I decided to try the script on my main library finally since I've backed everything up in another drive in case something goes wrong.

The script was going good apart from a few chokes of an error at every 2000/3000 files. I had deleted all the non-music files since it was having a bit problem moving those for some reason.

However, when the tracks surpassed 8000 out of 38000, the script started to malfunction and shoot the same error as the one it did before once in every 2000/3000 tracks. But this time, it was doing so once in every 5 or 6 albums. I found no problems with the files since they got processed in a breeze when I manually selected them and ran them through the script. My "Keep iTunes Media folder organised" option was disabled. The errors were -

User uploaded file

User uploaded file

And after that, I had to run the script all over again multiple times. That's really a problem since I don't want to be around for manual input and also since going through the older files once again is taking a lot of time.

Also, the script chokes at iTunes LPs, not that I had only 4 of them. I don't need a fix for that since I can put them away for now and restore them back later once the script is done.

Apr 14, 2018 8:54 AM in response to turingtest2

I'd keep 'The' in my naming, to be honest. And I guess the <AlbumArtist>/<Artist> thing would no longer cause any problems since I fixed all the <AlbumArtist> tags in my files just a while ago. Now there are zero tracks in my library that don't include the <AlbumArtist> tag. My concern here is the <DiscNumber> field. For example, there are files that have values like '1' or only '2' but most of the files are tagged as '1/2' or '2/2' or plain blank. I'm afraid I wouldn't want unnecessary subfolders to be created when there's nothing in the <DiscNumber> field.


For a file with no discnumber, the naming would be: "X:\Music\AlbumArtist - Album - Year - VBR/CBR\01 - File.mp3"

For a file with the discnumber being '2' or '2/2', the naming would be: "X:\Music\AlbumArtist - Album - Year - VBR/CBR\Disc 2\01 - File.mp3"


Please note that I want to discard the '/2' bit or the number of total discs in the naming. Also, I've dropped bitrate and would only include VBR/CBR in the name since VBR bitrates might create separate folders for each track with an estimated bitrate.

May 21, 2018 3:55 AM in response to turingtest2

Hello,

Really old thread but the <DiscNumber> portion seems to be generating a structure like -

X:\Music\<AlbumArtist> - <Album> - <Year>\Disc 0\<TrackNumber> - <Name> when the discnumber field is blank. And since all of my single-disc albums are like that, it's likely to create very unfavorable results.

If <DiscNumber> is less than 1 (blank), I'd like to have no additional subfolder created making it look somethink like this -

X:\Music\<AlbumArtist> - <Album> - <Year>\<TrackNumber> - <Name>

May 21, 2018 7:40 AM in response to arg274

I was thinking you would choose which pattern to use out of:


X:\Music\<AlbumArtist> - <Album> - <Year>\<TrackNumber> - <Name>

or

X:\Music\<AlbumArtist> - <Album> - <Year>\Disc <DiscNumber>\<TrackNumber> - <Name>


depending upon whether or not you're dealing with a single disc album or not, but I should be able to update the script to suppress Disc 0\ in the path of single disc albums, and while I'm at it probably 00 - for unnumbered tracks too.


tt2

May 21, 2018 4:01 PM in response to arg274

Copying to ' looks like an error, there should be a more sensible path there. Without looking at the script right now I could be making an assumption that iTunes has moved the file when instead the File System might be lagging. Disabling anti-virus, or excluding the media folder might help there. The second error is probably the result of another assumption when the code traverses folders trying to move album artwork with the tracks, and clean up folders that become empty.


I may not have time to look at this again for a few days as things are busy at work. Feel free to nudge me towards the weekend.


tt2

Apr 14, 2018 8:32 AM in response to arg274

Yes. iTunes turns everything that cannot be used in a Windows file path into an underscore, and limits file and folder names to 40 characters. I have a different set of custom replacements and will use up to 256 characters for the file path.


\ / * become -

: becomes ;

? becomes <nothing>

double quote becomes two single quotes

< becomes {

> becomes }

| becomes !


Again a chance for you to edit if you're really particular.


When my custom replacements are in use I also change The Value, to Value, The for artist and album folder names. I could split that out into its own option if you didn't want that. There's possibly some logic missing for when you've used <AlbumArtist> in the pattern but it is blank and could be inferred from <Artist>, or vice versa. I'd have to spend time revisiting the code to be sure.


tt2

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Batch Relinking of Missing iTunes files?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.