Search
Photos
Admin
« Mute/unmute the sound | Main | AppleScript, Email Announcer »
Thursday
Oct272005

AppleScript, "Open Safe Files" Folder Action


Continuing the AppleScript theme, here's the script that I wrote to use as a Folder Action. It automatically opens "safe" files after you download or copy them to the designated folder—I disabled this feature in Safari, since my understanding of "safe" is quite different from Safari's.

property safe_types_list : {
"org.gnu.gnu-tar-archive", "public.tar-archive",
"org.gnu.gnu-zip-archive", "org.gnu.gnu-zip-tar-archive",
"com.apple.binhex-archive", "com.apple.macbinary-archive",
"public.cpio-archive", "com.pkware.zip-archive",
"com.allume.stuffit-archive",
"com.apple.disk-image-udif", "public.iso-image"
}

on adding folder items to this_folder after receiving added_items

tell application "Finder"

repeat with a_file in added_items

set UTI to type identifier of (info for a_file)

-- display dialog UTI as string

if UTI is in safe_types_list then

open a_file

end if

end repeat

end tell

end adding folder items to



If you'd like this script to handle some additional file types, un-comment the display dialog UTI as string line, drop the file of the desired type into the folder and the script will display the type identifier that you need to add to the safe_types_list list.


Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>