Skip to content

Instantly share code, notes, and snippets.

@scalopus
Created April 17, 2020 13:32
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 scalopus/2037a8a682b193794b4dfd25bdac4f9d to your computer and use it in GitHub Desktop.
Save scalopus/2037a8a682b193794b4dfd25bdac4f9d to your computer and use it in GitHub Desktop.
File System Monitoring : PDF and then automatic decrypted the file to the new folder
# Useful for the Bank transaction / Statement / or same password
# which it enable us to just download to the folder and then the
# script will automatic decrpyted the password and store the new
# file without password needs.
# Pre-requirement
# apt install qpdf fswatch
export PASSWORD=<pdfpasswordhere>
export EXPORTDIR=./decrypt
fswatch --insensitive --include "\\.pdf$" --exclude ".*" \
--event Created --event Updated --event Renamed --event MovedTo \
-0 . | \
xargs -0 -n1 -t -I {} sh -c 'FILENAME=$(basename "{}"); \
qpdf --decrypt --password=$PASSWORD "$FILENAME" $EXPORTDIR/$FILENAME'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment