setting the "creator type" problems

Hi there,

The following code works just fine when run through Script Editor, but when I copy and paste it into a project within Project Builder (AppleScript Studio), I’m getting an syntax error. Studio seems to not recognise the “creator type” part of the call, I get the error of “A identifier can’t go after this identifier.” and it highlights “creator type”. Ideas anyone?


set file type of thePath to "Apzl"
set creator type of thePath to "AcRs"

Is the above code wrapped in a Finder tell block?

tell application "Finder"
	set file type of thePath to "Apzl"
	set creator type of thePath to "AcRs"
end tell

How can I get the following script to display the creator type and file type of a document file I drop on it?


on open docFile
	tell application "Finder"
		set fType to the file type of docFile
		set cType to the creator type of docFile
		display dialog fType & " " & cType
	end tell
end open

Thanks.
SA :smiley:

If you have Apple’s Developer Tools installed, you can use the ‘GetFileInfo’ command with this droplet…

on open the_item
	set this_item to (quoted form of POSIX path of the_item)
	do shell script "/Developer/Tools/GetFileInfo " & this_item
	display dialog result
end open

Try this, saved as an application. FYI, it will only work on a single file.

on open docFile
	tell application "Finder" to ¬
		set {fType, cType} to {file type, creator type} of first item of docFile
	display dialog "File Type: " & (fType as text) & return & "Creator Type: " & (cType as text)
end open

Ok I tried the following:


on open docFile
	tell application "Finder" to ¬
		set {fType, cType} to {file type, creator type} ¬
			of first item of docFile
	display dialog "File Type: " & (fType as text) ¬
		& return & "Creator Type: " & (cType as text)
end open

Whe I drop a file on the application I get a dialog box that displays the following:

File Type: missing value
Creator Type: missing value

Any ideas what I am doing wrong?

Thanks.
SA
:smiley:

Unfortunately, I don’t think that you have done anything wrong. It seems that in OS X, not all files have file types and creator types assigned to them. You are seeing the evidence of this.

macman13, your not doing anything wrong it’s just that many files in OS X are not using File Types &/or Creator Types. Try dopping a text clipping or an AppleScript onto your app and it will return the expected info. If a file does not have a File Type or a Creator Type, then your script will return “missing value”.