Skip to content

Instantly share code, notes, and snippets.

@komtaki
Created December 16, 2020 14:36
Show Gist options
  • Save komtaki/ebe139641ccc3d0c9119fa9f1aaffe05 to your computer and use it in GitHub Desktop.
Save komtaki/ebe139641ccc3d0c9119fa9f1aaffe05 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
readonly HOME_DIR=$(pwd)
readonly INPUT_DIR="${HOME_DIR}/dataset"
readonly RESULT_DIR="${HOME_DIR}/result"
if [ ! -d "${RESULT_DIR}" ]; then
mkdir "${RESULT_DIR}"
fi;
ls -1 "${INPUT_DIR}" | while read -r filePath
do
password="${filePath/'.pdf'/}"
echo "Succeed to lock!! filename: ${filePath} password: ${password}"
qpdf --encrypt "${password}" "${password[0]}" 40 -- "${INPUT_DIR}/${filePath}" "${RESULT_DIR}/${filePath}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment