October 2004
Beginner to intermediate
456 pages
12h 36m
English
Copy the album artwork of a selected track as aJPEG or PNG file to a specified folder.
This hack shows how to export the artwork from an iTunes track as a graphic file and save it to a selected folder, so you can start stockpiling your artwork for safekeeping or for use in other applications.
This script exports the artwork of the single selected track as a graphic file to a user-specified folder:
tell application "iTunes"
-- get a reference to selected track
if selection is not {} and (count items of selection) is 1 then
set theTrack to item 1 of selection
else
my alert_user_and_cancel("Please select one track.")
end if
-- does selected track have artwork?
if class of theTrack is not file track or ¬
artworks of theTrack is {} then
my alert_user_and_cancel("Selected track has no Artwork.")
end if
-- choose folder to save file to
set artFolder to (choose folder with prompt ¬
"Where do you want to save Artwork?") as string
-- get data and format of track's artwork
try
set artData to (data of artwork 1 of theTrack) as picture
set artFormat to (format of artwork 1 of theTrack) as string
if artFormat contains "JPEG" then
set extension to ".jpg"
else if artFormat contains "PNG" then
set extension to ".png"
end if
-- create name for new file
set theName to (artist of theTrack & " - " & album of theTrack) -- create paths for files set tempArtFile to (artFolder ...