Created
May 4, 2016 10:32
-
-
Save selankon/352daf294eb3e59c9053d323f93a6771 to your computer and use it in GitHub Desktop.
Convert multiple jpg to single pdf
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
#This script converts an amount of files of any type to a single pdf file. | |
#The files must be named: | |
# <NAME_OF_FILE><NUMBER>.<TYPE> | |
#This loop go over all the files converting its to .pdf in the /pdf folder using convert | |
#After merge all using pdfunite | |
#See convert man for more help about how to convert to pdf | |
START=1 #Start Number | |
END=38 #Final Number | |
NAME="firstaid" #File Name | |
OUT="out.pdf" #Output file Name | |
TYPE="jpg" #Type of image | |
LIST="" | |
touch $OUT | |
mkdir pdf | |
while [ $START -le $END ]; do | |
actual_file="$NAME$START.$TYPE" | |
pdf_name="pdf/$NAME$START.pdf" | |
echo "convert $actual_file $pdf_name" | |
convert "$actual_file $pdf_name" | |
LIST+=' '$pdf_name | |
START=START+1 | |
done | |
echo pdfunite $LIST $OUT | |
pdfunite $LIST $OUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment