Hello everyone,
I maintain two music libraries in iTunes. One is a lossless library, while the other is a lossy AAC library. Most of my AAC files are at 256Kbps and I’d like to re-covert my entire lossless library at 160Kbps VBR to save some hard drive space. Converting the files is the easy part. Getting them out of iTunes is not. The main problem appears to be iTunes’s inability to copy files with the same name. If I select all of my new AAC files and attempt to copy them to a folder (which I will then import into the other iTunes library), the copy operation fails. This is because some of my files have the same name (the same track by the same artist on two different albums, or a single, etc). Frustrating!!!
So, here’s my kludgey solution. First, create a Smart Folder in the Finder that scans the iTunes Music folder and looks for the new converted files. Then write an AppleScript that does the following:
- Assuming the Smart Folder is sorted by filename, start at the second file in the list.
- If the selected filename is the same as the previous file’s name, change the Finder label to red.
- If the Finder label is already red, change it to orange.
- Go to the next file.
This will basically distinguish the duplicate tracks from one another. At this point I will create a Smart Folder for each Finder label. Import the files with no labels first, then the red files, then the orange files.
Although the Smart Folder has no problem containing multiple files with the same name, when I try to import the files into iTunes, iTunes imports an incorrect number of files. I can only assume that it is having trouble with the duplicate file names. I think the labeling solution will allow me to separate these files and therefore not cause any confusion upon importing them.
Of course, if Apple only included support for multiple versions of the same track, I wouldn’t have this problem. But I digress…
So, being totally new to AppleScript, how do I do this? The logic seems obvious to me. I’ve been writing FileMaker Pro databases for years. If this was a set of FileMaker records, I could write this in five minutes. But, since I’m only marginally familiar with AppleScript, I’m a bit stumped.
Since Smart Folders aren’t real folders, how do I act upon the files? I’ve been able to count the files in the Smart Folder by counting the selected files. Next step would be initializing a counter variable, then looping through the files, counting up to the number of files in the selection before exiting the loop. This is where I am stumped.
Another option here would be to somehow manipulate the file names to ensure that they are unique (instead of using Finder labels). This seems like it might be a bit trickier to me, but perhaps not?
Any help, guidance, or references would be much appreciated.
Thanks!
-Rob