Skip to Content
iPod and iTunes Hacks
book

iPod and iTunes Hacks

by Hadley Stern
October 2004
Beginner to intermediate
456 pages
12h 36m
English
O'Reilly Media, Inc.
Content preview from iPod and iTunes Hacks

Save Artwork to a Folder

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.

The Code

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

iPOD & ITUNES for Dummies Portable Edition

iPOD & ITUNES for Dummies Portable Edition

Tony Bove
Windows Server® 2008 Active Directory® Resource Kit

Windows Server® 2008 Active Directory® Resource Kit

Conan Kezema Stan Riemer Mike Mulcare, Byron Wright, and Microsoft Active Directory
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 0596007787Supplemental ContentErrata Page