Created
November 17, 2019 17:35
-
-
Save nspo/fb239d3fcb07fa1fcedc168124e83d71 to your computer and use it in GitHub Desktop.
Automatically crop list of PDF files in place (no copy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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