Skip to content

Instantly share code, notes, and snippets.

@nspo
Created November 17, 2019 17:35
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 nspo/fb239d3fcb07fa1fcedc168124e83d71 to your computer and use it in GitHub Desktop.
Save nspo/fb239d3fcb07fa1fcedc168124e83d71 to your computer and use it in GitHub Desktop.
Automatically crop list of PDF files in place (no copy)
#!/bin/bash
for file in "$@"; do
echo "--- [$file]"
echo "- Cropping $file..."
pdfcrop --margin 5 $file /tmp/PDFCROP_TEMP.pdf
if [ $? -eq 0 ]; then
# success
echo "- Conversion successful. Replacing original file $file."
mv /tmp/PDFCROP_TEMP.pdf $file
else
echo "- Error while processing $file. Aborting."
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment