AppleScript Syntax

February 12 2008 - 2:26 pm

iTunes AppleScript Delete Bug Moreso

A lister on the AppleScript mailing list writes:

The Scripting Interface Guidelines agree with you: make and delete should be used to create/destroy objects completely, while add and remove should be used to add/remove existing objects to sub-groups. e.g. Compare Address Book, which uses add and remove to add/remove existing person objects to group objects. iTunes predates the SIG, however, and while its scripting interface is fairly extensive it does suffer a number of longstanding design quirks.

Yep. I'd be happy if they just made it like it used to be.

February 12 2008 - 9:12 am

iTunes 7.6 AppleScript Delete Bug

The more I think about the delete issue, mentioned below, the more I think this is a bug and not a feature. I have filed a bug report in any case. Although, I do like that you can trash a file from within iTunes, I do not like that you cannot preserve a track's file. A dandy way for delete to work would be as follows:

1) delete a track from a playlist to just remove it from the playlist.

2) delete a track from its Master Playlist to remove it from iTunes entirely but preserve the file (I tried this hoping it would work, but it does not).

2) delete a track from library playlist 1 to remove it from iTunes entirely AND trash its file.

(I don't know why there isn't a remove command in iTunes, which would make more syntactic sense. The Finder's AppleScript delete command will send a file to the Trash.)

Needless to say, this bug affects several scripts which use delete to remove a track from iTunes without actually trashing the file. For instance, Make Bookmarkable will delete a track from iTunes and then re-add it. Under iTunes 7.6, the track's file is moved to the Trash; when it is re-added, unless the user has "Copy files to iTunes Music folder when adding to library" checked in Preferences, iTunes will presume the track's location is the Trash. Empty the Trash and bye-bye file. This is exactly what is happening to some users.

I can only hope that Apple will see this as a serious bug--it being part of the AppleScript component of iTunes, I am sorry to say that I think it is doubtful--and fix it soon.

September 6 2007 - 8:52 am

iTunes 7.4 Released

iTunes 7.4 was released last night but I didn't get to it til this morning. New stuff! Album Ratings! My Good Friend Kirk McElhearn has observations on this new feature. I'm still looking into other AppleScript additions, but quite noticably there are three new track properties: album rating, album rating kind, and rating kind. The "kind" properties are read-only, but you can set album rating just like rating. I'll be posting a page of my findings later today.

June 30 2007 - 9:18 am

iTunes 7.3 - OSTypes Switched

A couple of Correspondents have noted that the OSType associated with the persistent ID property has changed to 'pPIS', which returns the persistent ID as a string. The previous OSType 'pPID' now returns a 64-bit number as in iTunes 7.1.1 and earlier. If you use raw Apple events to get this data then you may have to make some changes. (Thanks Milo and Manfred.)

May 30 2007 - 10:30 am

iTunes 7.2 AppleScript Changes

I'll be posting any AppleScript changes I find in iTunes 7.2 on this page.

May 30 2007 - 7:19 am

New reveal Command

iTunes 7.2 introduces the reveal AppleScript command. Given a track or playlist reference, it will select that track or playlist. Helpful!

March 7 2007 - 11:46 am

How To Write Your First AppleScript

Perceval McElhearn has posted How To Write Your First AppleScript at Macinstruct. It's a nice intro for those of you who want to get started. BTW: Perceval is the descendant of my good friend and Mac aficionado Kirk McElhearn. The nut don't fall far from the tree.

March 6 2007 - 3:22 pm

No More View library playlist 1

Correspondent George Dick reports--and I have verified--that you can no longer display library playlist 1, that is, the entire iTunes library, with a script such as this:

tell application "iTunes"
	set view of front browser window to library playlist 1
end tell


March 6 2007 - 9:45 am

NEW: Selected Tracks Played or Unplayed

Another new AppleScript track property in iTunes 7.1 is unplayed. This item does not appear in the GUI (not even in Smart Playlist criteria!?) but is accessible in the XML file, so I suspect this is something AppleTV may want to know about. In any case, you can set a selection of tracks as unplayed or played by setting the unplayed property to true or false, respectively. And that's what Selected Tracks Played or Unplayed does for a selection of tracks. Need I add for iTunes 7.1 or better only?

UPDATE: it appears the unplayed property may be specific to podcasts. However, the script will work with any track.

MORE UPDATE: do my TV Shows now have a blue dot on the far left indicating their played status?

January 11 2007 - 3:56 pm

-192 Error...the Finale

Well, I think this thing is nailed.

For those of you who have not been following along: several users have contacted me about a rare "Could not run this script because the required resources were not found. -192" error. This thing is so rare I have probably only seen it once or twice myself in my years of scripting. Here's the problem: my new "Installer" script that accompanies the latest .dmg download packages does not (currently) correctly copy AppleScript Studio apps. Some downloads use the "ProgBar" app, for example. In some download packages, the "ProgBar" app bundle is not completely copied; only its "Contents" folder is copied to your iTunes Scripts folder. This is totally fixable.

But here's the weird thing: when a folder named "Contents" is in your [username]/Library/iTunes/Scripts folder it somehow inhibits other scripts from running correctly.

What will happen is that when you run a script you will see its Splash Screen. None of the scripts from this site have been saved with this option. When you click the Run button, the -192 error appears.

Remove the "Contents" folder from your iTunes Scripts folder and the scripts will run correctly.

Here's what's weirder: create an empty folder named "Contents" in your iTunes Scripts folder and the same error occurs!

I am now updating the "Installer" script to handle AppleScript Studio apps correctly, and then this problem should disappear. If you are experiencing the -192 error, go to your [username]/Library/iTunes/Scripts folder and remove the folder name "Contents". In a few days, downloads which contain an AppleScript Studio application can be re-downloaded and re-installed correctly.

My sincere thanks to Correspondent Christian who figured out the "Contents" folder weirdness.

Site contents © 2001 - 2020 (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 interrupt the one doing it.