An attempt at a type/creator changing droplet

When I try to run this script, I get the error message: → Could not open the document because of an Apple event error. I’m using Script Editor 1.1.2.

on run
	open selection
	if suffix of filename is ".doc" then
		set creator to DVPR
	else
		if suffix of filename is ".jpg" then
			set creator to jade
		else
			display dialog "document could not be opened."
		end if
	end if
end run

Does this do what you want it to do?

tell application "Finder"
	set items_ to selection
	if items_ is {} then
		display dialog "No items selected."
		return -- quit
	end if
	
	repeat with item_ in items_
		if name of item_ ends with ".doc" then
			set creator type of item_ to "DVPR"
		else
			if name of item_ ends with ".jpg" then
				set creator type of item_ to "jade"
			else
				display dialog ("'" & (name of item_) & "' could not be opened.")
			end if
		end if
	end repeat
end tell

– Rob

Thanks, Rob! Now the script runs… you’re obviously a pro. :smiley:

Now it says “Can’t set «class fcrt» to “JADE”.

I don’t understand why it cannot. Do I perhaps need some kind of scripting addition to be able to change the creator code of a document? I’m using applescript on 8.1, so it isn’t the best applescript available, or the best OS. Nonetheless…

Hmm… it is a mystery.

:?

:smiley:

I tried the droplet today on an e-mail attachment and IT WORKED!

I was expecting it to work more like the type/creator apps I have on my computer, such as FileTyper.

Apparently, however, applescript automatically checks to see if the creator code being assigned to a document is appropriate to its type. My first test of the droplet was with a web archive to which I had added the suffix .jpg. That explains the error message. Very nifty.

Muy cool. Thanks again, Rob!