Skip to content

Instantly share code, notes, and snippets.

@BaksiLi
Created June 27, 2020 14:24
Show Gist options
  • Save BaksiLi/25b117c61963896f6c47c20704153fff to your computer and use it in GitHub Desktop.
Save BaksiLi/25b117c61963896f6c47c20704153fff to your computer and use it in GitHub Desktop.
Decrypt PDF by password stored in the Spotlight comment
#!/bin/bash
# Decrypt PDF by password stored in the Spotlight comment.
read -d '' Script << EOF
tell application "Finder"
set Comm to comment of (POSIX file "$1" as alias)
end tell
return Comm
EOF
COMMENT=$(osascript -e "$Script")
echo $COMMENT
qpdf --password="$COMMENT" --decrypt "$1" "${1/.pdf/.decrypt.pdf}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment