Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

When Xcode is installed your best bet to change a file's creator is SetFile.

I only found AppleScript. Unfortunately, while the type is set correctly, the second line silently fails on my 10.6:

set theFile to choose file
tell application "Finder"
    set file type of theFile to "TEXT"
    set creator type of theFile to "iDAT"
end tell

How can I change a file's creator code on a vanilla (just installed) system, even when Xcode is not installed?

share|improve this question
    
How are you determining that it failed? When I run the script on an arbitrary file, then run GetFileInfo -c afterward, it reports "iDAT". –  Daniel Lawson Sep 21 '11 at 15:28
1  
I get whatever creator it had before, usually "\0\0\0\0". And I tried on two machines. With a regular and an admin account. SetFile OTOH works fine. –  Tobias Sep 22 '11 at 14:10
1  
Why not just use SetFile? –  Mark Jan 16 '13 at 17:48

2 Answers 2

According to Wikipedia, in Snow Leopard, the Creator Code are ignored by Mac OS X.

On Textmate's Wiki, it's also advised to leave this field blank.

share|improve this answer
2  
True, but the field still exists and is still scriptable. While Finder ignores the field, third party Finder replacements could still use it. The OS still stores the metadata. –  Daniel Lawson Sep 21 '11 at 15:40
    
Yes, but maybe the problem is Finder. Since it was rewritten in Snow Leopard, they probably decided to stop allowing it to change this field. –  Loïc Wolff Sep 21 '11 at 15:46
1  
The Scripting Dictionary doesn't list the field as Read Only. And as I said above, when I ran the code on my machine (I tried it in SL and Lion), it did change the field. That's why I'm confused. –  Daniel Lawson Sep 21 '11 at 15:48
1  
I was asking how to change it, not why. In this case it's old software that refuses to open files it didn't "create". –  Tobias Sep 22 '11 at 14:12
    
Yep, I read the question wrong. I've updated it so that it'll get bump on the front page again and hopefully someone will know how to answer it. –  Loïc Wolff Oct 25 '11 at 16:10

I ran the following script on a variety of files on my system running 10.7.4. I ran it on files in my home directory, I ran it on files on a mounted FAT16 volume.

I was unable to get it to fail silently. If the file selected was locked or read only, the script failed with the error "Finder got an error: The operation can’t be completed because you don’t have the necessary permission."

Otherwise, in all the cases I tried, the script worked: regardless of the type and creator reported at the beginning, the type and creator reported at the end was TEXT and iDAT. Similarly, when I ran the script again on the same file, it initially reported type and creator of TEXT and iDAT, respectively.

So my advice would be to upgrade to Lion; if the script fails in 10.6, it seems to be a bug that has been fixed in 10.7.

set theFile to choose file
tell application "Finder"
    set myAlert to get file type of theFile
    display alert myAlert
    set myAlert to get creator type of theFile
    display alert myAlert
    set file type of theFile to "TEXT"
    set creator type of theFile to "iDAT"
    set myAlert to get file type of theFile
    display alert myAlert
    set myAlert to get creator type of theFile
    display alert myAlert
end tell
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.