Commands different between xcode and script editor

I’m running Xcode on a G5 in a user that has administrator rights. The following code works fine in the script editor.

set x to the file type of (info for filealias)

When I put the exact same line into my Xcode applescript application and try to compile the “file type” changes to “file kind” which is a totally different value in the “info for” command. I even tried typing (class asty) which compiled to “file type” but converted to “file kind” when I saved it.

Here is the last kicker. If I switch to a different admin user on the machine it compiles and saves fine but when I switch back to the first user it opens and appears fine until I try to save it again at which time it switches again to “file kind”.

Any leads will be greatly appreciated. Thanks in advance.

Greetings. Did you put your line in a finder ‘tell’ block? The finder is what’s doing the work here. The script itself doesn’t understand the “file type” request, so changes it to something it does understand…unfortunately it’s the wrong thing.

tell application "Finder"
  set x to the file type of (info for filealias) 
end tell

A search for “file kind” would have shown you the thread “file type changed to file kind in applescript studio”, which covers this exact issue.


Jobu, there should be absolutely no need to include that line in a Finder tell block. The Finder is NOT what’s doing the work there, the StandardAdditions.osax scripting addition is.

Standard Additions has an “info for” command, which is specifically designed to get information about files without using the Finder.

Just because Jon didn’t see that behavior doesn’t mean it doesn’t exist. It does, and it can be very intermittent in its occurrence. I’ve been plagued with it for months.

DCC, the key workaround is to use the Find and Replace in Xcode to replace all occurrences of “file kind” with “«class asty»”. Then, immediately save the script. This will leave you with a saved copy of the script that is correct. If you were to first compile the script by hitting Command-K, and then save it, you’d have undone your work. The Save command has an implicit compile command included in it, which would change “file type” back into “file kind”.

Basically, you’ll need to work on your script as it is, and ignore the fact that “file kind” is indeed incorrect until the very last step before you want to test the app. Once your satisfied with your code as it is and before you build the application, use that find and replace method, and then save the script. Then build the app, and you should have a version of the app that is free of this bug.

It’s a rather frustrating workaround but it works.

I’ll also add that at times, this bug seems to completely disappear, and you can compile the script all you want and “file type” will remain “file type”. I haven’t been able to pin down the reason for this yet.

Hope this helps…

As Mark says, others can attest that this is a very real bug (although, for whatever reason, it has failed to appear on my systems). What I said, however, is that “file type” is a class of either the Finder or of the Get Info record returned from the Standard Additions osax so it would either have to be inside a Finder block or used in the context of Get Info record as in:


not necessarily both.


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

You can also try:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thanks to everyone for the replies.

As a rule, I try to use the Finder as little as possible. It is a processor hog, and has caused me no end of trouble, especially when running more than one custom app at a time. In the past working on large numbers of files with the Finder either interferes with other apps and processes or just freezes the machine. Anyway, that is my experience with the Finder in OSX.

I’m going to use “set f to item 12 of ((info for (path to me)) as list)” while I’m working and then use the" «class asty»" switch when I’m ready for final test and deployment.

Thanks again to everyone.