iTunes: a How-To ques., re file maint. & Library

ChicagoLarry

Registered
Basic question:

Is there a way to update my Library simply by trashing it and re-importing the data (from my music files, which are not kept in iTunes), without losing my playlists?

If not, any thoughts on an easy way to keep the Library up-to-date as I ongoingly do maintenance on my music files? Manually, song by song is tedious.

The details:

I keep my 28,000 music files in heirarchical folders, not in my iTunes music folder.

I often do a huge amount of "maintenance" on my music files, such that the iTunes Library (the basic iTunes database) quickly gets out of date. Many items remain listed after the actual file has been trashed because it was a duplicate. Or I change file names. ...Numerous kinds of of tweaking to the files.

I COULD tediously go into iTunes and manually tweak the listing for each song I do maintenance on. But take this one example: I have hundreds of incomplete or damaged music files... I put them in a folder and sort by file size... I lop off a hundred of the smallest files and trash them (not likely worth saving)... Later I'll wade through the remaining ones, tossing some, saving some. None of this automatically gets reflected in the iTunes Library/database.

It would be much EASIER if I could periodically trash the iTunes library, and just reimport all my data into iTunes (from my actual music files, kept outside iTunes).

BUT I think all the playlists are tied to what's in the Library. Trash the Library and you've trashed all your playlists.

Any way to get around this? How can I save my playlists but have an easy way to "sync" my database periodically with my actual music files?

(Imo, one of the big flaws of iTunes is the inability to manage playlists, such as put them in nested folders, work with them separately, etc.)

If only iTunes would update itself when I work on my music files, and maybe it could do that to some extent if I kept my music in the iTunes Music folder; but that's irrelevant, since I don't (because I want to retain all control of my files... don't want Aunt Dorothy OR iTunes fooling around with my actual files when I can't always keep an eye on them!).

Any thoughts?

Thank you.
 
If you're just moving and renaming files, iTunes will automatically update its database if it's loaded. So whenever you do such operations, be sure to launch iTunes first.

I have never found the location of my music to make any difference in the way iTunes handles it. These days I keep it in my iTunes Music Library (you can turn off iTunes' auto-sorting, by the way, so it won't mess with your files at all), and I'm still faced with the same problems you have. It's a real bummer.

Back when iTunes 2 or 3 (I forget) came out, I did a large overhauling of my entire sorting system. I ditched all my playlists in favor of SMART playlists. To keep everything neat and orderly, I added little labels into the comments field of my mp3s. So any mp3 with "[1]" contained in the comments field would go into one of my smart playlist folders, anything with "[2]" would go in another, etc. With this method I could put any track in any number of playlists, and the playlist data would effectively be stored inside the mp3, so I could delete it from my iTunes Library, drag it back in, and it'd still be in all the right playlists.

I made a few AppleScript's to make the adding/removing of these labels easy.

As of iTunes 4, there's a new tag called "grouping", which is even better for this kind of thing than the comments tag. But I use the comments to maintain compatibility with the OS 9 version of iTunes, which can't display the Grouping.

The problem now, however, is that the rating and play count data will still be lost. For me, this is vital, so the "smart" system I was so proud of devising doesn't even cut it for me anymore. *sigh*

I suppose I could also make a script to dump the rating data into the comments/grouping field, and then another to convert it back upon re-insertion into the library. Hmmm.

ANYWAY, enough of my geekery. To answer your question as simply as I can, NO. iTunes does not go out of its way at all to make this kind of thing anything but a big fat pain in the keister.

If only Apple would completely dump the current format of the iTunes database and rely entirely on the xml version (which is always maintained for other iLife apps anyway), this would be a billion times easier. But for some reason they don't. *sigh*
 
Thank you, Mikuro.

You mention that changing file names and and moving files around will automatically get noted & updated in the iTunes Library (if changes are made while iTunes is open). But it apparently does not delete entries in the iTunes Library when a song file is deleted from the computer. I have tested that, with and without the Preference for "Keep iTunes Music Folder Organized."

So for that reason alone, I think I have to just occasionally dump my Library and reimport all my music into iTunes. To avoid losing my Playlists in this process, using Smart Playlists as you suggest seems to be the answer.

Another solution would be to delete all original files from within iTunes, but I often work with the original files (for extensive maintenance) and do not want to open iTunes and find a file every time I want to delete one--especially when I may be trashing numerous unrelated ones at a time.

Your suggestion about Playlists was great, thanks.

Here's another question, for you or anyone, many of my Comments do not show up in iTunes, even though the tag is Id3 tag is 3.2 or whatever the one is before you get to version 4. The Comments are there, in the tag (I can see them by opening the tag), and they are not scrambled.

I have "Converted" the tag to all the various options, even to version 4, but nothing works. Any idea how to make the Comments in the tag show up in the iTunes database (Library)?

Thanks.
 
ChicagoLarry said:
You mention that changing file names and and moving files around will automatically get noted & updated in the iTunes Library (if changes are made while iTunes is open). But it apparently does not delete entries in the iTunes Library when a song file is deleted from the computer.
Ah, that's true. It occurred to me, however, that I could probably whip up an AppleScript to check for missing tracks and remove them from your library. So I just did. In my short period of testing, it seems to get the job done nicely.
Code:
tell application "iTunes"
	set track_list to the selection
	
	repeat with track_num from 1 to the count of track_list
		set t to item track_num of track_list
		if the class of t is file track then
			set f to the location of t
			if f is missing value then delete t
		end if
	end repeat
end tell
Just paste that into Script Editor (located at "/Applications/AppleScript/Script Editor.app"), and hit run. It'll process all the tracks that are currently selected in iTunes. So if you want to do your whole library, just do a Select-All first. It'll will probably take a few minutes to process your whole library, though. But that's still probably shorter than doing it manually, anyway.

Oh, and I've only been testing it for about 5 minutes. So I'd make a backup of my iTunes Library before using it if I were you. And possibly my mp3s, too. [Edit: Also, I've only tested it with the latest iTunes, 5.0.1.]


As for your invisible comments problem, not a clue. That's a new one on me.
 
You're great, man! Thanks for the script. I look fwd to trying it.

As for the missing Comments, if no one else catches the question and answers it here, I'll post it later as a separate question.

Thanks again,
Larry
 
Back
Top