Skip to content

Instantly share code, notes, and snippets.

@Rafaeltheraven
Created August 13, 2024 10:30
Show Gist options
  • Select an option

  • Save Rafaeltheraven/53cef4039bf9804d519cb47f511ac7f5 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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
@Rafaeltheraven
Copy link
Author

Of note is that this may require sudo. If that is the case, just add a quick chown to the bottom of the script, or fix your permissions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment