I’m trying to write a couple of scripts for handling iTunes artwork “ here my code so far:
on getArtwork(dbID)
tell application "iTunes"
try
set c to (track 1 of library playlist 1 whose database ID is dbID)
return data of front artwork of c
end try
end tell
end getArtwork
on setArtwork(pic, art, alb)
tell application "iTunes"
set theseTracks to (every track of library playlist 1 whose (album is alb and artist is art))
repeat with i from 1 to count of theseTracks
set data of front artwork of (item i of theseTracks) to pic
end repeat
end tell
end setArtwork
set d to getArtwork(165)
setArtwork(d, "Men At Work", "Business As Usual")
Getting the artwork works without a problem, but storing artwork does not.
I get a parameter error on the line “set data of front artwork of (item i of theseTracks) to pic” “ why?
I don’t know what’s wrong with your script, but what I would do is break up the bad line making it easier to debug.
set data of front artwork of (item i of theseTracks) to pic
to:
set thisTrack to item i of theseTracks
set data of front artwork of thisTrack to pic
But you don’t need to use the index list method. This works for me:
tell application “iTunes”
set lib_pl to first library playlist
set first_track to first track of lib_pl
tell first_track
set {the_artist, the_album, d} to {artist, album, data of first artwork}
end tell
set track_list to tracks of lib_pl whose ¬
artist is the_artist and ¬
album is the_album
repeat with this_track in track_list
set data of first artwork of this_track to d
end repeat
end tell