Batch convert different image formats to multipage pdf Irfanview

804 Views Asked by At

I am new to batch scripting. I am trying to convert different image files into a multipage pdf file using Irfanview. The batch file needs to recurse through the subfolders and merge all of the image and pdf files into a multipage pdf file. The folders have different names. The files are in this format:

1_Applicant_20220301_PDF.pdf
2_Picture_applicant.jpg
3_Picture_image.png
4_MyDocument_image.heic
5_index.xml    
6_textfile.txt

The end result should be 1 pdf file with all the files merged together without the xml file.

@echo on
SETLOCAL EnableDelayedExpansion
SET startDir=C:\Test
SET destdir=C:\Test\Testi\Out
MD %destdir% 2>nul
for /f "tokens=* delims=" %%i in ( 'dir /b/s*.pdf,*.jpg,*.heic,*.png,*.txt' ) do
FOR /f %%a IN ( 'dir /b %%i*.pdf' ) DO (

"C:\Program Files (x86)\IrfanView\i_view32.exe" /multipdf=("C:\%%i\out.pdf,*.pdf,*.jpg,*.heic,*.png,*.txt") /cmdexit
)
pause
::for /f "tokens=1 delims=." %i in ( 'dir /b/s *.pdf,*.jpg,*.tif') do echo %i
:: passes fullfilepath excluding fileextension C:\filepath\filename
:: for /f "tokens=* delims=" %i in ( 'dir /b/s ::*.pdf,*.jp*g,*.heic,*.png,*.ti*f,*.txt') do echo %%i

Any assistance is appreciated.

0

There are 0 best solutions below