Returning constants to php/OSAScript

I am trying to return the “special kind” property of a iTunes playlist
When running the script in the script editor, it returns “Party Shuffle”, when i run
osascript testscript.scpt in terminal, or calls it from php, it returns
«constant ****kSpS»–«constant ****kSpS»

Is there any way that I can get the text value of the constant returned?
I tried to split the characters of the constant into a list and putting them toghether again, but the result was the same

tell application "iTunes"
	set out to ""
	repeat with plist in user playlists
		set out to ((special kind of plist) as text)
		exit repeat
	end repeat
	set out to (out as text)
	set out to characters 1 thru (number of characters in out) of out
	--set out to all characters of out
	set out2 to ""
	repeat with ttt in out
		set out2 to out2 & ttt
	end repeat
	return out2
end tell

How about this…

set plist_record to {}
tell application "iTunes"
	set plists to every user playlist
	repeat with a_plist in plists
		set end of plist_record to {plistName:(name of a_plist), specialKind:(special kind of a_plist) as string}
	end repeat
end tell
get plist_record

Jacques: Tested your solution from the terminal, and it works perfectly.

regulus6633: Have not tested your solution in the actual project, but when testing it using terminal it returned the following info: osascript testscript2.scpt
plistName:Partymiks, specialKind:«constant ****kSpS»,

Thank you both for helping me solv the problem.

Anyone got an answer for the question, how to return the constant string?


You’ll only get a human-readable representation if the AppleScript component has previously loaded the iTunes dictionary, which it only does when compiling scripts.

The simplest thing would be to save your script in uncompiled form (testscript.applescript), so osascript automatically compiles it each time it’s run.

Alternatively, you could add a ‘run script’ command to your script that compiles a simple iTunes script, again forcing AppleScript to load the relevant terminology, e.g.:

run script "tell application \"iTunes\" to get name"


Just saved my file as text and used the name testcript.applescript and it worked.
I suspect there is a performance cost of doing it like this vs precompiled script, but calling osascript from php causes a delay to start with.