OSX and File Types Question

I have not yet begun coding for OSX so I am going to ask what is potentially a stupid question. I am putting together a proposal for a client who is concerned about paying for a solution that will not be compatible with OSX. The solution is 100% Finder scripting and I don’t see any major problems with portability but the client is under the impression that file types are obsolete under OSX. Is this true? I don’t see how that can be true or why the new platform would eleminate file types. Are file types different under OSX?

Thanks,
Scott

According to Finder’s dictionary, and my experience, they are still alive in OS X 10.2.6. You could give him this script and let him explore to see if he encounters anything that might cause a problem.

set file_ to (choose file with prompt "Select any file.")

tell application "Finder"
	set {type_, creator_} to {file type, creator type} of file_
end tell

display dialog "File type: " & type_ & return & "Creator type: " & creator_

Update: I just checked a php file and it returned ‘missing value’ for both. The file is mapped to BBEdit (it has a BBEdit icon), but it came from a source which likely didn’t use a Mac to generate the file. For files that are created on a Mac, everything should be ok.

For what little it’s worth…

I’ve run into this on OS 10.1.4 (which is all I have at present).

Some items return ‘missing value’ for both file type and creator type… making it hard to reliably sort, select or ‘tell’ them by these means.

Both file and creator types may be readily ‘set’, however.

If I recall correctly, there was a thread at the AS Mailing List about this and the ‘future’ - in particular - of creator types. It seems some application developers simply aren’t using them at present.

Peter B.

Some files still have creator and file types and several do not. You can use this script to see what the (if any) creator and file types are for files dropped on it…

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

It requires Apple’s Developer Tools

Hi,

I’ve just posted another version of this question in bevvyb’s post “Script works on one machine, but not another…”

My experience is that every time I copy a short “filetyper” script to another OS X machine, which includes this tell block:

	tell application "Finder"
		repeat with x in theList
			set file type of x to "spcF"
			set creator type of x to "MapF"
		end repeat
	end tell

I get an error, and the following appears in the script:

	tell application "Finder"
		repeat with x in theList
			set <<class fitp>> of x to "spcF"
			set creator type of x to "MapF" 
		end repeat
	end tell

When I then edit the script, on the “new” machine and replace the “<>” with “file type”, the script compiles, and runs properly thereafter.

Please excuse this “second” posting, especially if it is contrary to “good” BBS etiquette.

For kicks, I tried to run a modified version this code (OS X 10.2.6). It returned this error message:

Finder got an error: Can’t get file type obsolete of alias “path:to:my:file”.

I wonder if your compiled script has saved some type of internal pointer/reference to something that’s no longer valid. Perhaps Apple has changed the underlying code that allows scripts to get file type. I’m not a programmer so it’s all pure BS…er…speculation. :wink:


For kicks, I tried to run a modified version this code (OS X 10.2.6). It returned this error message:

Finder got an error: Can’t get file type obsolete of alias “path:to:my:file”.
[/quote]

Is this because you have used the syntax ‘<>’ rather than the syntax ‘file type’? I’ve always been confused about the ‘<>’ syntax, and have yet to find a good way of interpreting and understanding the ‘xyz’ portion of the class.

I’ve expanded the other discussion thread as well: http://bbs.applescript.net/viewtopic.php?t=4045

Cheers,