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 library
using 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
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