Skip to content

Instantly share code, notes, and snippets.

@prateekrajgautam
Last active June 18, 2021 09:46
Show Gist options
  • Save prateekrajgautam/f892d853d60bb70c6fe5cc6ffc9c281f to your computer and use it in GitHub Desktop.
Save prateekrajgautam/f892d853d60bb70c6fe5cc6ffc9c281f to your computer and use it in GitHub Desktop.
PDF to JPG batch conversion on linux
#!/bin/bash
sudo apt-get install poppler-utils
mkdir ConvertedJPG
echo "hi"
for f in *
do
echo "converting" $f
pdftoppm -jpeg -rx 300 -ry 300 "$f" JPG
echo "moving converted JPG to " $f "\n"
mkdir "./ConvertedJPG/$f"
mv *.jpg "./ConvertedJPG/$f/"
done
## It will convert all the pdf in script folder to JPG in their respective names
##First Page only in seprate folder
#!/bin/bash
sudo apt-get install poppler-utils
mkdir FistPageJPG
echo "hi"
for f in *
do
echo "converting" $f
#pdftoppm -jpeg -rx 300 -ry 300 "$f" JPG
pdftoppm -jpeg -r 300 -f 1 -l 1 "$f" "$f"
echo "moving converted JPG to " $f "\n"
mv *.jpg "./FistPageJPG/"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment