以下代码使用nconvert
将多个tiff
图片合并为一个pdf
文件。我的问题是:每当一个“文档或pdf文件”应该只包含一个tiff图像时,脚本就会崩溃。如果任何人都可以看一下脚本,并且对于为什么会出现这种情况有任何想法,我们将不胜感激。
$InputLocation = "C:\Convert"
$output = "C:\Convert"
$Inputbdf = "C:\Convert\0001.bdf"
$patternCN = "\|([^\|]*)\|([^\|]*)\|"
$patternD = "(\d)/\d\d/(\d\d\d\d)"
$docs = gci "$inputLocation\*0001.tif"
$docs.count
foreach($tiff in $docs){
$pattern = $tiff.FullName.Substring($tiff.FullName.length-12,4)
$patternI = "$pattern.*"
$pages = gci "$inputLocation\$pattern*.tif"
$pagen = $pages.count
$lines = Get-Content($inputbdf)|
Foreach-object{
write-host $PatternI
if($_ -match "C:\\[some folder]\\$patternI.TIF$patternCN$patternD"){
$a = $matches[2]
$b = $matches[1]
$c = $matches[4]
$d = $matches[3]
}
}
if((test-path -path "$output\$c") -eq $false){
New-Item $output\$c -type directory
if((test-path -path "$output\$c\$d") -eq $false){
new-Item $output\$c\$d -type directory
}
}
$tiff = $tiff.Name.split('.')[0]
cd C:\[my desktop folder]\Nconvert\XnView
#./nconvert -help > nchelp.txt
.\nconvert.exe -quiet -out pdf -c 3 -multi -n 1 $pagen 1 -o "$output\$c\$d\$a$b.pdf" "$InputLocation\$pattern####.tif"
}