]>
git.rmz.io Git - dotfiles.git/blob - bin/crack_pdf
   7 This script will decrypt any pdf given to it. The correct password has to be passed. 
  13  -p <password>      The password to be used 
  18 # checks if 'qpdf' is installed 
  19 type -P qpdf 
&>/dev
/null 
|| { echo "I require qpdf but it's not installed.  Aborting." >&2; exit 1; } 
  23 while getopts "hp:v" OPT
; do 
  44 if [[ -z $ARGS ]] || [[ -z $PWD ]] || ! type -P qpdf 
&> /dev
/null
; then 
  49 shopt -s nullglob       
# w/o this '*.pdf' will return the string if no pdfs are in the folder 
  51     if [[ -d $DST ]]; then 
  52         for F 
in $DST/*.pdf
; do 
  53             [[ $VERBOSE ]] && echo $F 
  55             qpdf 
--password=$PWD --decrypt $F ${F%.pdf}_.pdf 
|| echo "error" 
  58     elif [[ ${DST##*.} = "pdf" ]] && [[ -f $DST ]]; then 
  59         [[ $VERBOSE ]] && echo $DST 
  60         qpdf 
--password=$PWD --decrypt $DST ${DST%.pdf}_.pdf