[Screenshot of code at URL in tweet, the script first uses "find" to locate the files, and passes them to a while loop. It creates a clean PDF at a temporary file, removing it if one exists already. Code follows] # Color Codes so that warnings/errors stick out GREEN="\e[32m" RED="\e[31m" CLEAR="\e[0m" # loop through all PDFs in first argument ($1), # or use '.' (this directory) if not given DIR="${1:-.}" echo "Cleaning PDFs in directory $DIR" # use find to locate files, pip to while read to get the # whole line instead of space delimited # Note -- this will find pdfs recursively!! find $DIR -type f -name "*.pdf" | while read -r i do # output file as original filename with suffix _clean.pdf TMP=${i%.*}_clean.pdf # remove the temporary file if it already exists if [ -f "$TMP" ]; then rm "$TMP"; fi exiftool -q -q -all:all= "$i" -o "$TMP" qpdf --linearize --replace-input "$TMP" echo -e $(printf "${GREEN}Processed ${RED}${i} ${CLEAR}as ${GREEN}${TMP}${CLEAR}"
https://social-coop-media.ams3.cdn.digitaloceanspaces.com/media_attachments/files/107/686/442/772/750/424/original/f5b43f49b4762cd1.jpg