Re: Working with creator codes in OS X
Re: Working with creator codes in OS X
- Subject: Re: Working with creator codes in OS X
- From: Axel Luttgens <email@hidden>
- Date: Wed, 29 Aug 2001 09:58:13 +0200
- Organization: ---
Alexander Hertzog wrote :
>
I'm trying to create a script for OS X that will *remove* the creator
>
codes from a set of files [...]
Your post in fact covers lots of things. So, I'll begin with your sample
script, so as to get rid of the programmatic aspects of your question (in
what follows, I assume scripting under OSX).
A preliminary note here: if the "try" part works, source_folder will be set
to a Finder's reference; otherwise, it will be set to an alias.
Such programming is likely to lead to big big headaches when trying to
track errors.
>
try
>
tell application "Finder" to set the source_folder to (folder of
>
the front window) as alias
>
on error -- no open folder windows
>
set the source_folder to path to desktop folder as alias
>
end try
This will set item_list to a list of strings:
>
set the item_list to list folder source_folder without invisibles
But then you are trying to set the creator type of strings:
>
repeat with i from 1 to number of items in the item_list
>
set the creator type of item i to ""
>
end repeat
>
I got the error message, "Can't use identifier type after identifier
>
creator" or words to that effect. So I removed the word "type" so the
>
line just read "set the creator of item..." This gave me the error
>
message, "Couldn't set creator of item 1 to """ and gave me a similar
>
error when I used " " (four spaces instead of nothing).
Only Finder's files may have a property called 'creator type';
AppleScript's strings don't. So, you first need to ensure that you're
working onto the right object.
Second, you need to use Finder's terminoly to be sure that property
'creator type' will be correctly recognized; that is, you must use it
within a 'tell app "Finder"' block.
So, assuming that source_folder contains a valid reference to the folder
containing the files you want to alter, and that new_creator contains a
four-characters string, you could try something like this:
tell application "Finder"
set item_list to contents of source_folder
repeat with i in item_list
set creator type of i to new_creator
end
end
But that's not the whole story...
>
Does OS X handle Finder selections differently than OS 9? Does OS X
>
handle creator codes differently than OS 9?
Selections don't seem to differ.
But creator types, well...
Strictly speaking, OSX doesn't use creator and file types; it could even
know nothing about them, wouldn't there be the need of compatibility with
Classic.
So, trying to set the creator type of a pure OSX's file won't work, because
it doesn't have one (look at the result of 'get properties of some_file' on
an OSX's file, and then on a Classic's file).
And now, my question: what do you exactly mean by "removing" a file's
creator type?
Either you are working on a file that HAS a creator type; then you can only
change it to another four-characters code (at least, through "normal"
ways).
Or it hasn't a creator type; and then you don't have anything more to do...
It looks as if your intent where somewhat different than "removing"; could
you be more precise?
Hope this helps,
Axel