Created
August 2, 2017 17:18
-
-
Save cwg999/89f81f70bd7263d2d9b37abcc3aab4fa to your computer and use it in GitHub Desktop.
A Powershell Script that reads a path and recursively lists pdfs with more than one page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ArrayList = [System.Collections.ArrayList]@() | |
# $i = $ArrayList.add('echo "Hello"') | |
Get-ChildItem -Path .\ -Recurse | Where-Object { | |
$_ -is [System.IO.FileInfo] ` | |
-and ($_.Directory.Name -eq 'Single') | |
} | ForEach-Object { | |
$ArrayList.add($_.FullName) | |
# $output = iex "& $command" | |
# $pages = $output.Substring(15,$output.length-15) | |
# Write-Host $_.FullName '|' $pages | |
# if((0+$pages) -gt 1){ | |
# Write-Host $_.FullName '|' $pages | |
# } | |
} | |
workflow Test-Workflow{ | |
param( | |
[Parameter (Mandatory = $true)] | |
[System.Collections.ArrayList]$ArrayList | |
) | |
ForEach -Parallel -throttlelimit 5 ($file in $ArrayList) | |
{ | |
$command = '"E:\Program Files (x86)\PDFtk Server\bin\pdftk.exe" "'+$file+'" dump_data | findstr NumberOfPages' | |
$output = iex "& $command" | |
$pages = $output.Substring(15,$output.length-15) | |
if($pages -gt 1){ | |
Write-Output $file $pages | |
} | |
# Write-Output $output | |
} | |
} | |
Test-Workflow -ArrayList ($ArrayList) | |
Write-Host "Press any key to continue ..." | |
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | |
Write-Host "Finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment