Skip to content

Instantly share code, notes, and snippets.

@joshbetz
Last active December 12, 2015 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshbetz/4686756 to your computer and use it in GitHub Desktop.
Save joshbetz/4686756 to your computer and use it in GitHub Desktop.
Secure files with Hazel
-- Set password and file name
set itemPath to quoted form of (POSIX path of theFile)
set passwd to do shell script "openssl rand -base64 32"
set hash to do shell script "openssl sha1 " & itemPath & " | awk -F'= ' '{print $2}'"
-- set file name
tell application "Finder"
set file_name to name of theFile
set file_name to text 1 thru ((offset of "." in file_name) - 1) of file_name
set file_ext to name extension of theFile
set the_folder to POSIX path of (container of theFile as alias)
set the clipboard to passwd as text
end tell
set zipFile to file_name & "-" & hash & ".zip"
set zipPath to quoted form of (POSIX path of the_folder & zipFile)
-- zip the file
do shell script "zip -P " & passwd & " -rj " & zipPath & " " & itemPath
-- delete the original
do shell script "rm -rf " & itemPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment