Bulk Combine TIFFs Based on Common File Name Using Irfanview

821 Views Asked by At

I have a folder containing 2000 or so single page TIFFs. The TIFFs have a variable number of common file names that indicate how the files should be combined. The common file names are different lengths. Using Windows 7, standard productivity software and Irfanview available to me at the moment.

I am trying to parse through the folder and combine the TIFFs based on the common file name.

For example, we have the following files in the folder: sample.1.tiff, sample.2.tiff, samplefoo.1.tiff, samplefoo.2.tiff, samplefoo.3.tiff.

After running the batch process, we would have the following multi-page TIFFs (or PDFs, etc.) in the folder: sample.tiff (containing sample.1.tiff and sample.2.tiff), samplefoo.tiff (and samplefoo.1.tiff, samplefoo.2.tiff, and samplefoo.3.tiff).

We can do it by hand but I am reasonably sure there's a way to do this in Irfanview or through VBA. I welcome any thoughts or suggestions.

1

There are 1 best solutions below

0
On

Found the following Irfanview script on a message board and tweaked for my fact pattern:

@ECHO OFF
SETLOCAL enabledelayedexpansion
SET destdir=C:\Test\
MD %destdir% 2>NUL
FOR /f "delims=." %%i IN ( ' dir/b *.*.tif ' ) DO IF NOT EXIST %destdir%\%%i.tif (
(SET srctiff=)
FOR /f %%a IN ( ' dir/b %%i.*.tif ' ) DO (
IF DEFINED srctiff (SET srctiff=!srctiff!,%%a
) ELSE (SET srctiff=%%a)
)
"C:\Program Files (x86)\IrfanView\i_view32.exe"/multitif=^(%destdir%\%%i.tif,!srctiff!^) /cmdexit
) 

Worked like a charm with some limitations depending on numbering and if the page numbers have leading zeroes.