dougscripts.com

AppleScript Changes in iTunes 4.7

iTunes 4.7 was released on October 26, 2004. The new version was introduced by Steve Jobs and Bono and The Edge of U2 as part of the iPod Photo/Special Edition U2 iPod announcement. Also released was QuickTime 6.5.2 and iPod Updater 3.0.4. New features in iTunes 4.7 include "Show Duplicate Songs", various Preference pane updates, the ability to accommodate PDF files, and other "unspecified" performance improvements. iPod Photo is a next-generation iPod that allows color photos to be viewed and the creation of slideshows using photos and music.

 

Overview of AppleScript Features

iTunes 4.7 introduces a new property of the EQ preset class called update tracks. Setting this property to true will enable the targeted EQ preset to be updated when the preset is renamed or deleted. It looks like the default value is true.

(I hadn't noticed this before, so I could just be ignorant or perhaps I just hadn't updated my iPod software recently enough, but when you send a track to iPod with a custom EQ, the EQ goes with it. So the track will keep its EQ preset on iPod, even though that preset will not be listed in the iPod's EQ selection. There are also a number of extra features on my iPod—a Gen 1—that weren't there before: Clicker, Contrast, stuff like that.)

A new command has been added called eject. This will, well, eject the iPod. My assumption is that it will not update the iPod first, unless you use that command as well. I "Manually Manage" my iPod, so I haven't tested this. Here's the syntax:

tell application "iTunes"
	set src to first source whose kind is iPod
	eject src
end tell

This is the same as hitting the iPod eject button on iTunes or selecting Eject "iPod" from the Controls menu, or tapping Command-E.

Weirdness - the "Selection Bug"

No one has confirmed this for me yet, however I have experienced a strange effect regarding the selection object of the application class. When using Script Editor to run this:

tell application "iTunes"
	get selection
end tell

The result is an empty list, rather than the expected list of track references. However, it appears that compiled scripts targeting the application selection run from the iTunes Scripts menu work fine.

To get the correct result in Script Editor, you have to target the front browser window's selection object. You will note that the application class and the window class each have a selection property. So running the following in Script Editor works:

tell application "iTunes"
	get selection of front browser window
end tell

I have also noticed the errant result when running scripts saved as applications. I have to do some more testing to narrow it down. While it does make sense to target the window selection, I'm wondering what the application selection is supposed to reference? No answers yet.

[UPDATE 04.12.22] It has been pointed out to me that by merely adding an activate command after targeting iTunes, the application selection object is correctly targeted, like so:

tell application "iTunes"
	activate
	set sel to selection
end tell

This may not always be desirable. You may not want to bring iTunes to the front everytime you need to access the selection. Even so, interesting!

Other Stuff

The most prominent new feature in iTunes 4.7 is the addition of the "Show Duplicate Songs" command under the Edit menu. This will create a playlist displaying duplicates based on Song Name and Artist. Tracking dupplicates has been, without a doubt, the biggest problem for users. Many are nitpicking that there should be more criteria available, such as Size and Duration. However, this new feature goes a long way in helping people track down duplicates for themselves and I warmly commend the iTunes Guys for including it.

The iTunes Preferences now has an iPod pane, which is the same as clicking on the iPod Options button. Advanced Peferences now has a checkbox to allow the minimized version of the iTunes browser to remain "on top" of other windows and apps and in focus—very cool. AirTunes preferences are now located in the Audio preferences pane

PDF "Digital Booklets"

Fascinatingly, iTunes can now handle PDF files. This accommodation was made specifically for the U2 box set, which contains a "Digital Booklet" of esoterica. The "booklet" is a PDF file which appears in the iTunes library as a "track" and can be assigned tags. The PDF can be opened in Preview when double-clicked in iTunes. The possibilities for this PDF accommodation are considerable. Kirk McElhearn quite nicely discusses some possibilities. You can create your own PDF file of lyrics, artwork, production notes, set lists, etcetera, and by creatively setting the tags of the PDF "track", associate it with an Album or Artist. I have written PDF Adder to assist with adding a PDF file to iTunes and tagging it with a selected track's Artist and Album tags.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.