Powershell 计数if循环中的文件
如何计算在powershell中输入if语句的文件数? 这是我的Powershell 计数if循环中的文件,powershell,Powershell,如何计算在powershell中输入if语句的文件数? 这是我的 foreach($tiff in $tiffs2){ if($tiff.FullName.Substring($tiff.FullName.length-12,4) -eq $pattern){ $tiff = $tiff.Name.split('.')[0] cd C:\Users\xxxxxxx\Desktop\Nconvert\XnView
foreach($tiff in $tiffs2){
if($tiff.FullName.Substring($tiff.FullName.length-12,4) -eq $pattern){
$tiff = $tiff.Name.split('.')[0]
cd C:\Users\xxxxxxx\Desktop\Nconvert\XnView
#./nconvert -help > nchelp.txt
.\nconvert.exe -out pdf -c 3 -multi -n 1 $pages 1 -o "$output\$tiff.pdf" "$InputLocation\*.tif"
}
}
}
如何计算if语句中的文件数?当然可以使用计数器。:-)
通过在每次迭代中增加一个计数器,如果我没有完全弄错的话……我该如何准确地写出它呢?
$ctr = 0
foreach($tiff in $tiffs2)
{
if($tiff.FullName.Substring($tiff.FullName.length-12,4) -eq $pattern)
{
$ctr++
$tiff = $tiff.Name.split('.')[0]
cd C:\Users\xxxxxxx\Desktop\Nconvert\XnView
#./nconvert -help > nchelp.txt
.\nconvert.exe -out pdf -c 3 -multi -n 1 $pages 1 -o "$output\$tiff.pdf" "$InputLocation\*.tif"
}
}