Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
macOS Automator Action to calculate file hashes
on run {input, parameters}
with timeout of 360 seconds
tell application "System Events"
display dialog input buttons {"OK"} default button 1 with title "File Hashes" giving up after 300 --seconds
end tell
end timeout
end run
for file; do
if [[ -d "$file" ]]; then
echo "$(basename "$file") is a directory"
cd "$(dirname "$file")"
printf "File: $(basename "$file")"
printf "\n\nMD5: "
/usr/bin/openssl md5 "$(basename "$file")" | egrep -o [a-f0-9]{32}
printf "\nSHA1: "
shasum -a 1 "$(basename "$file")" | egrep -o [a-f0-9]{40}
printf "\nSHA256: "
shasum -a 256 "$(basename "$file")" | egrep -o [a-f0-9]{64}
done | tr "\n" "\r"

This comment has been minimized.

Copy link
Owner Author

@oelna oelna commented Jun 21, 2018

Working from the quite perfect code sample on Superuser I made an Automator service to display the MD5, SHA1 and SHA256 hashes for a file via the Services context menu.


  • Make new Automator service
  • Set to "Service receives selected files or folders in
  • Run Shell Script
  • Run Applescript applescript.scpt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment