Wednesday, October 26, 2011

Batch convert PDFs to multipage TIFFs

Here's a powershell script that uses Ghostscript to convert a directory full of PDFs to multipage TIFF files.  This will convert all PDFs found in $input_path to a TIFF file that is placed in $output_path.  Note, the original file is then deleted.  Thanks to

Set $tool to the correct path for Ghostscript and set $input_path and $output_path accordingly.

$tool = 'C:\Program Files (x86)\gs\gs9.02\bin\gswin32c.exe'
$input_path = 'C:\input\'
$output_path = 'C:\output\'
$pdfs = get-childitem $input_path -recurse | where {$_.Extension -match "pdf"}

foreach($pdf in $pdfs)

    $tiff = $output_path + $pdf.PSChildName.split('.')[0] + '.tiff'
    if(test-path $tiff)
        "tiff file already exists " + $tiff
        'Processing ' + $pdf.Name        
        $param = "-sOutputFile=$tiff"
        & $tool -q -dNOPAUSE -sDEVICE=tiffg4 $param -r300 $pdf.FullName -c quit
        Remove-Item $pdf.FullName

1 comment:

Mariya Pinto said...

Thanks for sharing knowledgeable blog which provide the information about the conversion of Batch convert PDFs to multipage TIFFs. Great blog!!

Multipage Tiff Convert