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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

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

Publisher Resources

ISBN: 0596007787Errata Page