IrfanView: Command Line Batch Conversion

3.2k Views Asked by At

A) I'd like to Batch convert from *.TIF Format Packbit Conversion to LZW Conversion, overwrite the original file BUT maintain the original folder structure automatically. This can easily be done in the Batch GUI of Irfanview (I did that already, ask me how If you'd like to do the same, sth similar)

B) I want to do the same as A) but only pick Pictures with the same file ending (*xyz.tif) and also maintain the folder structure! I think this bit can be prepared with python os.walk maybe?!

1

There are 1 best solutions below

0
On

Me and a colleague figured out a solution, which rarely can be found in IrfanView Documentations or various communities I guess.. This one Loops through a Folder structure (with os.walk) and converts each tif with a specific ending (*xyz.tif in this case) from Packbit Format to LZW Format and overwrites it. The original Folder structure will thus be maintained. I think it is a quite usefull script for various conversion Tasks (also from tif to jpeg for example).

import os

IVIEW32_PATH = 'C:\Program Files (x86)\IrfanView\i_view32.exe'
SOURCE_FILETYPE = 'tif'
TARGET_FILETYPE = 'tif'
PATH = r'D:\OriginalFolderxyz'

for dirpath, subdirs, files in os.walk(PATH):
    print dirpath
    command = '"%s" '%IVIEW32_PATH + dirpath + r"\*_col.%s /tifc=1 /convert="%(SOURCE_FILETYPE) + dirpath + r"\*_xyz.%s"%TARGET_FILETYPE
    os.system(command)
print "ended...*.xyz.tif"