Batch file to bundle JPGs into multi-page TIF

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
wallywalters
Posts: 9
Joined: Sat Sep 25, 2010 2:18 am

Batch file to bundle JPGs into multi-page TIF

Post by wallywalters » Sat Oct 07, 2017 2:27 am

I'm trying to write a batch file I can drag-and-drop a bunch of black-and-white scans onto and combine them into a single, multi-page TIF. But instead of the output TIF files getting joined together, each new TIF file overwrites the last one. Is there any way to do what I'm trying to do? The code I'm using is:

Code: Select all

nConvert.exe -out tiff -multi -binary nodither -c 7 -rMeta %1

User avatar
xnview
Author of XnView
Posts: 30094
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Batch file to bundle JPGs into multi-page TIF

Post by xnview » Sat Oct 07, 2017 10:46 am

Something like that?

Code: Select all

nConvert.exe -out tiff -o out.tif -multi -binary nodither -c 7 -rMeta file1.tif file2.tif
Pierre.

cday
XnThusiast
Posts: 1843
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Batch file to bundle JPGs into multi-page TIF

Post by cday » Sat Oct 07, 2017 3:15 pm

xnview wrote:Something like that?

Code: Select all

nConvert.exe -out tiff -o out.tif -multi -binary nodither -c 7 -rMeta file1.tif file2.tif
You can list the files to be processed, as above, or use a filelist (-l option) or use *.jpg, which would probably be the usual way to process a number of files in a folder...

Is your concern to be able to process many files quickly?

I'm not experienced enough to be familiar with the %1 option, and I normally avoid drag and drop, so I'm possibly not not the best person to help, but I would probably use a batch file to convert folders of files using *.jpg, either using Input and Output folders or a single Process folder. Possibly a folder of files can be dragged onto a script?

wallywalters
Posts: 9
Joined: Sat Sep 25, 2010 2:18 am

Re: Batch file to bundle JPGs into multi-page TIF

Post by wallywalters » Sat Oct 07, 2017 3:20 pm

Thanks, Pierre, but unfortunately that requires the filenames to be known and written into the batch code, which means we can't do "drag and drop." But I think I've ultimately figured out an (admittedly clunky) way to do this.

Code: Select all

@echo off
set nPATH=C:\Program Files\XnView

:GetFile
  set Test=%~1
  if "%Test%"=="" goto :JoinFiles
  "%nPATH%\nConvert.exe" -out tiff -o "temp_%~nx1.tif" -multi -binary nodither -c 7 -rMeta %1
  shift
  goto :GetFile

:JoinFiles
  if not exist temp_*.tif goto :Checkout
  "%nPATH%\nConvert.exe" -out tiff -o "OUTPUT.tif" -multi -binary nodither -c 7 -rMeta temp_*.tif
  del temp_*.tif

:Checkout
  echo DONE
  pause
Last edited by wallywalters on Sat Oct 07, 2017 4:19 pm, edited 1 time in total.

cday
XnThusiast
Posts: 1843
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Batch file to bundle JPGs into multi-page TIF

Post by cday » Sat Oct 07, 2017 3:23 pm

I posted while you were posting so we crossed, please see my post above...

I've since, depending on clarification of what you wish to do, had another idea of how you could use drag and drop:

o Drag and drop an arbitray number of files into a folder;

o Run [double-click] a script that uses *.jpg as input;

o Include a second line in the script that deletes *.jpg files in the above folder.

That way you should be able to repeatedly drag and drop an arbitrary number of JPEG into a folder that will just contain an increasing number of multi-page TIFFs.

wallywalters
Posts: 9
Joined: Sat Sep 25, 2010 2:18 am

Re: Batch file to bundle JPGs into multi-page TIF

Post by wallywalters » Sat Oct 07, 2017 4:21 pm

Looks like I just "crossed" the same way you did, editing my earlier post at the same time you posted. Thanks for your suggestions; I'll try them too.

Post Reply