Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Python img2pdf Shell Batch Processing Script to Convert All Images in Sub Folders to PDF Documents

Posted on December 13, 2022

 

 

Welcome folks today in this blog post we will be converting all images in root and sub folders to pdf document using a simple shell batch processing script using the python library img2pdf.

 

 

Get Started

 

 

In order to get started guys you need to install the below libraryusing the pip command as shown below

 

 

pip install img2pdf

 

 

After installing this you need to make a img2pdf.sh file inside the root directory and copy paste the following code

 

 

img2pdf.sh

 

 

Shell
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
#set -xf
TOPDIR=$PWD
dirs=($(find . -type d))
for dir in "${dirs[@]}"; do
  echo $dir
  cd $dir
  #echo $PWD
  img2pdf --out $dir.pdf *.{jpg,png}
  cd $TOPDIR
done

 

 

As you can see in the above shell script we are finding all the jpg and png images present inside the root directory and the sub directories and converting them to the pdf documents. If you now want to run this make sure you open the git bash terminal inside the visual studio code as shown below

 

 

Recent Posts

  • Node.js Puppeteer Project to Export Handlebars Resume Template to PDF Document in Express Using Javascript
  • Node.js Express Passwordless Login Example to Send Magic Auth Link Using Nodemailer
  • Python 3 Tkinter Script to Encrypt PDF Documents With Password Using PyPDF2 Library GUI Desktop App
  • Node.js Express Project to Upload Image Buffer & BLOB Data to MongoDB Database & Display it in Browser Using Javascript
  • Node.js Tutorial to Export Images to PDF Document With Effects Using FilePix Library in Javascript
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme