Haneef Puttur

Batch creation of Batch PDF file from Multiple jpg files – Step By Step

Task : I want to create PDF files of 1000 students records. Each student record have 2 pages. Each page is named in the following format

IDNUMBER_PageNo.jpg

Example of one students :

20151101234.jpg

20151101234_001.jpg

These are the records of one students scanned as jpg. The task is make them as pdf file with a file name : 20151101234.pdf

Note that , I have 1000 student records with 2000 jpg files. I have to make 1000 PDF files out of these 2000 jpg files.

Tools Required :

Free Download : http://www.imagemagick.org/script/binary-releases.php

For 64 Bit , Windows 7 , I downloaded this Version => http://www.imagemagick.org/download/binaries/ImageMagick-6.9.2-0-Q16-x64-dll.exe

Theory:

Using ImageMagick if you wish to combine multiple jpeg and create single pdf , then you should use following command

convert file1.jpg file2.jpg file3.jpg file.pdf

Steps Involved :

  1. Create a folder and put all jpg files inside it.
  2. Extract the file names , paste to Excel Sheet
  3. Create a batch script in the format required by Imagemagick
  4. Install Imagemagick Software and Test
  5. Enjooooooy

Step1 :

Create a folder in c Drive as Haneef and paste all the files there

Step2

Open Command Prompt

cd c:\haneef
dir *.* /b >> haneef.txt

This will create a file called haneef.txt , which contains all file names present in the folder

Now open the txt file created by above script

Now we need to extract the ID number from the file names we captured using command prompt

For  that, copy paste the entire content of the file into one column of an excel  sheet

Use an Excel formula in the column B

=Left(A2,9)  

This will extract 9 digits from the left side of the file name 
Now we notice that , there are multiple rows with same ID number as each ID have two jpg files
For that , use Remove Duplicate function of Excel as Follows.

NOw our excel sheet is ready with B column containing the ID numbers of all students.

Now our task is to create a script which will match the syntax requirement of ImageMagick,

convert file1.jpg file2.jpg file3.jpg file.pdf

For that use an formula in the column C of excel sheet as follows.

 

="convert "&B2&".jpg "&B2&"_001.jpg "&B2&".pdf"

After that, extend the cell values to entire column by dragging as shown.

Now Install IMageMagick software if not already done.

http://www.imagemagick.org/download/binaries/ImageMagick-6.9.2-0-Q16-x64-dll.exe

 

After running the setup of above software open command prompt and test by entering Convert in the command prompt screen

If the system says , cannot find file means , you may need to restart your machine.

If everything is fine , please copy the script to command prompt.

Now copy the content of column C

Again open command prompt and Paste the content of script from excel

Now system will start creating individual PDF files with file name IDnumber.pdf

Now you can see the output in the folder

Filter for only PDF files as shown and copy all the out put files to folder of your choice

I made this as much step simple as possible to make sure even person with basic computer knowledge can follow the concept and move on.

Enjoooy Scripting

 .

Exit mobile version