Convert image files to multiple outputs

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

Moderators: XnTriq, helmut, xnview

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

Convert image files to multiple outputs

Post by cday »

The following batch file, developed in response to a request in the XnConvert section of the forum for a way of creating multiple versions of the files in multiple folders of images directly, may be of wider interest. A batch file that processes a single source folder of images should only require some minor edits.

The script, saved as a batch file .bat, for each folder of source images named 'TIFF' in the folder 'Images' creates three versions of the images in that folder, HiRes, MidRes and Thumbs, each version placed in a sub-folder with the relevant name, in the folder.

Code: Select all

FOR /D %%Y IN ("C:\X\Images\*") DO (

MD "%%Y\HiRes"
nconvert -out jpeg  -q 100 -o "%%Y\HiRes\%%.jpg" "%%Y\TIFF\*.tif*"

MD "%%Y\MidRes"
nconvert -dpi 150 -ratio -rtype lanczos -resize 50%% 50%% -out jpeg -q 100 -o "%%Y\MidRes\%%.jpg" "%%Y\HiRes\*.jpg"

MD "%%Y\Thumbs"
nconvert -dpi 72 -ratio -rtype lanczos -resize longest 280 -out jpeg -q 100 -o "%%Y\Thumbs\%%.jpg" "%%Y\MidRes\*.jpg"


The detailed processing to create the required new images was specified by the original poster, the batch file structure manages the overall process.

The original poster specified that each successive version be produced from the previous version; successive versions could alternatively have been produced directly from the original source TIFF images.