I have a document scanner that can only scans to single page tiffs and I need to combine them into multipage tiffs. I know Irfanview can do this, however I am open to other options.
Input, C:\Scans
:
20161001115151800_0001.tif 20161001115151800_0002.tif ... up to ... 20161001115151800_0021.tif
...and...:
20161002130918260_0001.tif 20161002130918260_0002.tif ... up to ... 20161002130918260_0025.tif
Desired Output, C:\Output
:
20161001115151800.tif 20161002130918260.tif
I am seeking a solution similar to Bulk Combine TIFFs Based on Common File Name Using Irfanview and ImageMagick: how to batch combine multiple TIFF file to a single TIFF file in a directory? however I cannot figure out how to implement the first solution as a batch file with my file structure, and the second solution uses sequential filenames which I cannot produce.
Any help is greatly appreciated!
In program files folder of IrfanView there is the text file i_options.txt
listing and explaining the available command line options. Examples for creating multi-page TIFF files are also included in this file.
I suggest to use additionally the option /tifc=X
after /cmdexit
in the IrfanView command line in the batch code below to define the compression to use for the multi-page TIFF file(s).
@echo off
if not exist "C:\Output\" md "C:\Output"
for %%I in ("C:\Scans\*_*.tif") do (
for /F "delims=_" %%J in ("%%~nI") do (
if not exist "C:\Output\%%J.tif" (
"%ProgramFiles(x86)%\IrfanView\i_view32.exe" /cmdexit "/multitif=(C:\Output\%%J.tif,C:\Scans\%%J_*.tif)"
)
)
)
The /multitif
option is enclosed in double quotes to avoid the need of escaping the parentheses and getting the entire option passed to IrfanView as one parameter string even if the name of current file contains a space character or another character which usually requires the usage of surrounding double quotes. Run in a command prompt window cmd /?
and read at least last paragraph on last page in output help about usage of double quotes.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
echo /?
for /?
if /?
md /?