Checking against an application's generically named enumerated type


In my iTunes AppleScript (using AppleScript 2.0.1 under Mac OS X 10.5.5), I am trying to test the “video kind” property of a track. This property is an enumerated type listed in the dictionary as (none/movie/music video/TV show). I can test against the last 3 types, but I am having a problem with “none”.

So, this works …

if (video kind of track trackIndex of library playlist 1) is not in {movie, music video, TV show} then

but this does not …

if (video kind of track trackIndex of library playlist 1) is none then

They both compile and execute, but the second statement retrieves no records, while the first retrieves many records.

I am guessing that the “none” type is so generically named that AppleScript may be assuming the wrong value (from another app or something).

As I thought about it, various properties and enumerated types are so generically named that they must often conflict with other applications or within the same application.

So, can someone tell me how to specify that I am referring to the

Thanks in advance,


try this

if (video kind of track trackIndex of playlist "Podcasts") as text is "none" then

Hi Stefan,

I had tried that before (and once again now to be safe ;)) based on a code snippet I saw in Doug’s iTunes AppleScripts. However, for me (with AppleScript 2.0.1, Mac OS X 10.5.5, and iTunes 8.0.1), it yielded zero results. Does it work for you?

I imagine that AppleScript can not translate an enumerated type to a text string. If anything, it should be able to at least translate it to a number, but when I try to coerce it “as integer” (assuming the enumerated type translates to a 0), it says this can’t be done :frowning:

Any other ideas are much appreciated.

Thanks again,


Yes, within a tell application “iTunes” block it works (also iTunes 8.0.1 OS 10.5.5)

Hmmm … my whole 100 lines of code is within the


Could there be something else different/wrong with my environment?

I’ve tested it with this (silly) code, my playlist “Podcasts” contains both none and movie tracks

property myPlayList : "Podcasts"

tell application "iTunes"
	repeat with trackIndex from 1 to (count tracks of playlist myPlayList)
		set {video kind:video_kind, name:_name} to track trackIndex of playlist myPlayList
		if video_kind as text is "none" then
			display dialog _name & " - " & "none"
			say video_kind as text
		end if
	end repeat
end tell

Hi Stefan,

Again, thanks for taking the time to help me!

So, with your script, I realize that my “video kind” values translate to strange “constant-type” text. For instance, instead of “none”, my “video kind” tracks with “none” values get translated to the text for the core constant: “«constant ****kVdN»”. If I test against this strange string, then I get the result I want! So, thanks for pointing me in that direction.

Beyond this, do you know if there is a setting or something that I could change which is causing me to get these different results than you (and others)? So, I can test against the English-like values.



This happens actually only, if the comparison is outside the iTunes tell block,
or within a tell block of another application.

Do you have any Scripting Additions installed, which has also an enumeration none?

I have no other “tell” block defined in my script. Either way, to keep it simple, we can focus on your simple script that I tested, since I have the same issue with it.

I am sure I have the “Standard Scripting Additions” installed (even though I do not believe I explicitly installed it), since I can use the “display dialog” and other such commands. Is the “Standard Scripting Additions” what you are referring to? If so, do you also have it installed, since you do not have the problem with your simple script?

By the way, I just thought of something. For major performance benefits, I am running all my iTunes AppleScripts from the iTunes Scripts folder/menu. Perhaps, since it is running internal to iTunes there are some issues … are you running it like this or externally

By the way, when you run a script within an application framework, is the “tell” block still needed for that application?

Well I answered some of my own questions.

  1. “none” works fine for me when run externally; internal execution must affect conflicting enumerated types like

  2. “tell” block is still needed for internally run scripts due to “Script Editor” compilation

Standard Additions are installed anyway, so I don’t refer to this.
I’m using the commercial Script Editor “Script Debugger” by LateNight Software,
but it could be, that the scripts behave different being run form the script menu or Script Editor / Script Debugger.

What do you mean with “application framework”?

Hi Stefan,

Just to be safe, let me clarify:

  1. I use Apple Script Editor to compile/save as a “script”

  2. Like other Mac applications, iTunes has its own “script menu” to directly execute scripts (only those located in the /Users//Library/iTunes/Scripts folder). This is different than the general “script” menu that can be added to the menu bar with the AppleScript utility.

  3. When I ran your simple script from within the iTunes script menu, it would not identify “none”. When I ran it externally (from within the Apple Script Editor), it worked fine and properly identified “none”.

  4. When I ran my iTunes AppleScripts “externally” (from Script Editor or as a saved application), they were extremely slow … almost 30 minutes to process 9,500 tracks! However, when I run the same scripts from within the iTunes script menu (and saved as “scripts” not “applications”), the same logic takes about 30 seconds! If you have iTunes scripts and have not already done so, I HIGHLY recommend running them from the iTunes script folder/menu.

  5. I noticed that Mac Office 2008 Excel has a similar script menu (again, not related to the general “script menu”) to run Excel AppleScripts.

  6. So, by “within an application framework”, I am referring to the script being executed/called from “within an application” - just like iTunes and Excel do from their own script menus. This execution of scripts seems to communicate much faster with the application’s framework (referencing iTunes playlists, etc.). In addition, I am guessing that here is where enumerated types with conflicting “friendly” names have issues and are forced to be resolved with the internal codes.

  7. I just started AppleScripting and I consider the Apple Script Editor to be pretty decent. I see that I can move to the free XCode development environment (I downloaded it with the iPhone SDK) when I am ready for more sophistication. Any reason you prefer this third-party script editor that you use?

  8. So are there other Scripting Additions that I can install to get more power? Are these from Apple?



  1. I got it. You need always to use application tell blocks. AppleScript works completely independent from any application

  2. As the name implies, Script Debugger is perfect to debug scripts with step by step execution, breakpoints etc.
    Xcode can do similar things, but the preferred language of Xcode is Objective-C. In my opinion Script Debugger is more powerful than Xcode concerning AppleScript

  3. There are no further scripting additions provided by Apple. But there are lots of thirty party additions. The power depends on what you’re going to accomplish