I have tracked an intermittent error down in one of my iTunes scripts to the fact that tracks I’m modifying no longer match the source smart playlist criteria so the object reference (I apologize if my terminology is incorrect) becomes invalid. The slow access time of the SD card where the data is stored gives the smart playlist time to update (before when I used an external hard drive it did not). This behavior wasn’t what I was expecting so it took me a while to figure out, and then only by experiment: copying all the tracks from the smart playlist to a “dumb” one and then performing my track modifications on a list derived from that made the occasional error disappear. I’ve looked for a more elegant solution, but my search attempts have been unsuccessful.
Here are my ideas for possible methods of improvement, limited by my ignorance. Further suggestions are most welcome:
-
Create an Applescript list of objects in a way that the object references don’t become invalid if the smart playlist changes. Maybe there’s a standard way to do this? I had naively assumed it’d work this way by default.
-
Programmatically toggle “live updating” off for the smart playlist and then back on again after I’m done. The iTunes dictionary doesn’t show anything about this so I am not hopeful.
-
Stick with copying the tracks to a “dumb” playlist before messing with them, but optimize how it is done.
Thank you very much for any suggestions.