Convert Multi File of PNM to PDF

Convert Multi File of PNM to PDF

I have lots of pnm which is scanned files. PNM is picture format. I need to make them into one file. The only way is convert them into pdf. And make them into one file.

Linux provides such command. Which is convert command. The syntax is simple like this :

#convert source.pnm output.pdf

The problem is I have 40 file that I need to convert. Is there a way to make automation to do the process in single command? Yes of course. A guy in this forum suggested to create bash script. Here one inside the bash :

for f in *.pnm; do
	convert ./"$f" ./"${f%.jpg}.pdf"
	echo ./"$f"  "berhasil"

I named the bash script And make it executable by adding chmod.

#chmod +x

Then I put it in the pnm directory and execute it.


It works like a charm.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.