Archive for December, 2010

December 28 '10 - 1:19 pm
Get a Track Reference from a File Path

Correspondent Wayne B. recently wondered if there is a way to get a reference to a track in iTunes based on its file path. Well, unfortunately, you can’t do something like this:

tell application "iTunes"
	set trackRef  to (get some file track of library playlist 1 whose location is "some/file/path.ext")
end tell

That will generate an error. But you can trick iTunes into giving you the track reference by using the add command–if you are certain the file is already in iTunes’ database. When you add the file iTunes will check its database for the the corresponding library track for you and if it exists will give up the reference–and it won’t re-add it:

set theFile to choose file
-- or however you get the file path

tell application "iTunes"
	try
		set trackRef to (add theFile as alias)
		tell trackRef
			log (get name)
			# and so on...
		end tell
	end try
end tell


But remember that if the file isn’t already in iTunes’ database then iTunes will add the file as a matter of course, which may not be what you want. So this trick may work best only when you know a file is currently in your library.

You will not want to use the open command instead of add, because open will compel iTunes to play the file in addition to any add-housekeeping.

December 15 '10 - 6:23 pm
iTunes 10.1.1 Available

Looks like some minor fixes are available in iTunes 10.1.1.

December 15 '10 - 3:22 pm
iBooks v1.2 Available

Apple has posted iBooks v1.2 for iOS devices with some cool new features including PDF and notes printing and Collections creation for books and PDFs.

Site contents © 2001 - 2014 Doug Adams and weblished by Doug Adams, dougscripts AT mac DOT com. About.
All rights reserved. Legal.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc.