I am submitting to you this wicked simple (but really useful) AppleScript that I made. This script is like a lot of the others I've seen in the AppleScript listing, EXCEPT...in those others, you have to change the creator code in the script every time.
Not in this one. This one opens a dialog box when you drop a file on it. The dialog box contains the file name and file type, but puts the creator code in a default answer box, allowing you to edit it right there. No more editing the script every time. This has come in really handy for me because I deal with cross-platform all the time, and I'm too lazy to edit the script every time I need this thing, which is several times a day.
on open (theList)
tell application "Finder"
repeat with theItem in theList
if class of theItem is file then
set locked of theItem to false
end if
set fileName to name of theItem
set fileType to file type of theItem
set creatorType to creator type of theItem
set dialogResult to display dialog "File name: " & fileName & return & ¬
"File Type: " & fileType & return & "Creator Code: " buttons "OK" ¬
default button 1 default answer creatorType
set creatorType to text returned of dialogResult
set creator type of theItem to creatorType
end repeat
end tell
end open
- Using ResEdit, open the AppleScript program you made.
- Create a new 'cicn' resource.
- Draw or paste a new color or B&W icon, and a mask for it.
- Now choose the new icon resource and press Command-I.
- Type a four or five digit number in the 'ID' box.
Remeber the number. Whenever you want to use that icon, use that number. The icon will not be visible in the Script Editor. Only in the Finder after you save it to disk and run it from there.
A better way to reference the icon is to set up a property within your script (property iconName : iconNumber) with a name of choice and the number you gave it. For Example :
Then you can reference the icon with that name (in this case, myLogo). Then you can reference the icon like this :
The icon won't be displayed when run in the Script Editor. You have to save it and run it as an application from the Finder.
Evan Francois adds this comment:
One must be sure it's **their** script displaying the dialog. For example, if the display dialog statement falls within a tell application "Finder", end tell block, it won't work. In cases like that, be sure to nest the display dialog statement within a tell me, end tell pair.