Skip to content

Instantly share code, notes, and snippets.

@nall
Created September 30, 2009 03:31
Show Gist options
  • Save nall/197734 to your computer and use it in GitHub Desktop.
Save nall/197734 to your computer and use it in GitHub Desktop.
Applescript to automount encrypted image
(*
Automount Encrypted Image
This script monitors for a volume to be attached and upon detection, mounts an encrypted image on that volume
This folder action is intended to be used on /Volumes. When it's detected that /Volumes/<theVolume> is attached, it will automatically try to attach /Volumes/<theVolume>/<theEncryptedVolume>
Copyright © 2008-2009, Jon Nall, STUNTAZ!!!.
*)
on adding folder items to this_folder after receiving added_items
set hdiutil to "/usr/bin/hdiutil"
set theVolume to "GillSans"
set theEncryptedImage to "GillSansUltraBold.sparsebundle"
try
tell application "Finder"
repeat with theItem in added_items
set theName to name of theItem
if theName is equal to theVolume then
set thePath to POSIX path of theItem
set theCmd to hdiutil & " attach " & thePath & theEncryptedImage
do shell script theCmd
end if
end repeat
end tell
end try
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment