I’m writing a script to run through a playlist and ‘clean up’ the broken location items by replacing them with a best fit from MainLibrary. So far it will correctly identify the song for replacement and it will duplicate (copy) the song into the playlist, but I am unable to find a way to re-organize the track so that it is in the right playlist location (index?) instead of at the bottom of the playlist. I’ve searched high and low and while a solution is probably out there, I haven’t yet found it (help!)
This is my first script. Here is a code snippet, and I’m happy to share the whole thing (so far) if/as needed.
–Find the good track with the same attributes; filter for those of similar attributes
set possible_tracks to (every file track of main_playlist whose name = nom and album = alb and genre = gen and kind = knd and location is not missing value)
if possible_tracks is not {} then
duplicate item 1 of possible_tracks to this_playlist
–Arrange track to the same position as the track it is replacing, then remove the duplicate track that’s missing location information
end if