Tiff to multipage Tiff in distinct folder

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

Moderators: XnTriq, helmut, xnview

Post Reply
AurelSea63
Posts: 2
Joined: Tue Dec 26, 2017 10:37 am

Tiff to multipage Tiff in distinct folder

Post by AurelSea63 »

Hi all,

I need to do this :

I have :
Folder_1 = 1.tiff, 2.tiff, 3.tiff
Folder_2 = 1.tiff, 2.tiff, 3.tiff

I want :
Folder_1 = 1.tiff multipage who include (1.tiff, 2.tiff, 3.tiff)
Folder_2 = 1.tiff multipage who include (1.tiff, 2.tiff, 3.tiff)

I want to do mass conversion on multiple folders at the same time, is it possible ?

Thx for help everyone :)
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Tiff to multipage Tiff in distinct folder

Post by cday »

AurelSea63 wrote:I need to do this :

I have :
Folder_1 = 1.tiff, 2.tiff, 3.tiff
Folder_2 = 1.tiff, 2.tiff, 3.tiff

I want :
Folder_1 = 1.tiff multipage who include (1.tiff, 2.tiff, 3.tiff)
Folder_2 = 1.tiff multipage who include (1.tiff, 2.tiff, 3.tiff)

I want to do mass conversion on multiple folders at the same time, is it possible ?
Using NConvert on Windows?

If your need were limited to a small number of folders, one solution would be to use the following example code run in a batch file .bat:

Code: Select all

nconvert -multi -out tiff -o $$/Multi.tif  Folder_1/*.tif
nconvert -multi -out tiff -o $$/Multi.tif  Folder_2/*.tif
Note that:

o I tested using the .tif extension rather than the equally valid as far as I know .tiff extension;

o The $$ notation saves entering the specific folder name, as a slight simplification.

o You will probably wish to insert a compression option after the -out tiff term above, please consult the help file for that.

o If your output multi-TIFF file uses the same filename as one of the input files there will be a conflict: a solution would be to delete the input single-TIFF files as they are read by inserting -D early in the code.

Always test using copies of your original files... :wink:

A more general solution probably requires a FOR loop I think: very few more experienced members post on NConvert topics, but I may have a look myself as I may have a generally similar need coming up.
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Tiff to multipage Tiff in distinct folder

Post by cday »

Further:

If you place your folders Folder_1, Folder_2 ... into a folder 'Process' the following code should perform the operation you requested:

Code: Select all

For /d %%Y in ("Process/*") do (

nconvert -D -multi -out tiff -o "Process/%%Y/Multi.tif"  "Process/%%Y/*.tif"

)
Notes:

The -D term deletes the original single-image TIFFs after they have been processed, if you wish to retain them remove that term.

Select the TIFF extension used to suit your files.

The double quotes " " should enable filenames containing spaces to be processed.

The above code uses relative addressing as that is the way I work, if necessary use the full paths.

You still need to add suitable compression to the multi-page TIFFs created, the appropriate type depending on your needs.

Again, always test using copies of your original files... :wink:

E&OE: I don't pretend to understand the above code! :D

Edited:

Double quotes added to the 'for' line.
AurelSea63
Posts: 2
Joined: Tue Dec 26, 2017 10:37 am

Re: Tiff to multipage Tiff in distinct folder

Post by AurelSea63 »

Thx for help guys, i'm gonna try this now. I give u my feedback soon :)
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Tiff to multipage Tiff in distinct folder

Post by cday »

Important update:

The code that I posted above used forward slashes (/) in paths, and produced the desired result in my tests.

I was nonetheless in a general way aware that code run on the Windows command line should normally use back slashes (\) as path separators, although in practice either path separator can often be used. However, further research in relation to similar code that I need myself has indicated that when forward slashes are used code may not always run as expected.

This code I posted using forward slashes worked in my tests...

Code: Select all

For /d %%Y in ("Process/*") do (

nconvert -multi -out tiff -o "Process/%%Y/Multi.tif"  "Process/%%Y/*.tif"

)
... but when backslashes are substituted the above code no longer runs, and the following notably different code is required:

Code: Select all

For /d %%Y in ("Process\*") do (

nconvert -multi -out tiff -o "%%Y\Multi.tif"  "%%Y\*.tif"

)
That code is notably different and should I think be regarded as the more appropriate solution.

Anyone able to make a useful contribution please post...
Post Reply