Created
August 13, 2024 10:30
-
-
Save Rafaeltheraven/53cef4039bf9804d519cb47f511ac7f5 to your computer and use it in GitHub Desktop.
A bash script to make scanning (multiple) pages into a single PDF easy
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 | |
| filename="$1" | |
| if [[ "$filename" == "" ]] | |
| then | |
| filename="scan" | |
| fi | |
| fin=False | |
| let "i=0" | |
| mkdir /tmp/scan2pdf | |
| while [ $fin = False ] | |
| do | |
| scan /tmp/scan2pdf/"$filename"_"$i".png | |
| read -p "Do you want to scan another page? [Y/n] " yn | |
| case $yn in | |
| [Nn]* ) fin=True;; | |
| * ) let "i=i+1";; | |
| esac | |
| done | |
| convert /tmp/scan2pdf/*.png "$filename".pdf | |
| echo "Done scanning, removing tmp folder" | |
| rm -r /tmp/scan2pdf | |
| echo "Stripping metadata" | |
| { | |
| exiftool -all:all= "$filename".pdf | |
| } &> /dev/null | |
| rm "$filename".pdf_original |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of note is that this may require
sudo. If that is the case, just add a quickchownto the bottom of the script, or fix your permissions