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

Swap Song Name and Artist

Correct that irritating problem of’ song names and artist names being reversed.

The first time you find a track in iTunes that somehow has gotten its Song Name and Artist reversed, you open up its Get Info window and do some cutting, copying, pasting, and typing to effect repairs. It’s kind of a drag. When you see the same problem with another track, you begrudgingly do the swap a second time and hope that you won’t have to go through all that again. But when you notice it a third time, don’t lose your temper. Just break out the AppleScript.

The Code

This script gets the text from the nameand artistproperties of each of the selected tracks—or, if no tracks are selected, all the tracks in the selected playlist—and swaps them:

	tell application "iTunes"
	 -- act on particular tracks or all tracks currently displayed
	 if selection is not {} then
	   set sel to selection
	 else
	   set sel to file tracks of view of front window
	 end if

	 -- loop through each selected track
	 repeat with aTrack in sel
	   tell aTrack
	     set temp1 to (get name)
		 set name to (get artist)
		 set artist to temp1
		end tell
	  end repeat
    end tell

The first thing the script does is determine which tracks the user has selected for swapping. If none are selected, the script acts on all the tracks of the currently selected playlist. In either case, the list of tracks to be acted upon by the script is stowed away in a variable ...

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