Last active
December 12, 2015 00:49
-
-
Save joshbetz/4686756 to your computer and use it in GitHub Desktop.
Secure files with Hazel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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