Skip to content

Instantly share code, notes, and snippets.

@cwg999
Created February 12, 2019 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwg999/d1e0e662b141fcb36a47ceb6070d9634 to your computer and use it in GitHub Desktop.
Save cwg999/d1e0e662b141fcb36a47ceb6070d9634 to your computer and use it in GitHub Desktop.
If PDFs match size and page length criteria, open them in chrome. Searches two folders "Single" and "Multiple" within the starting directory.
Get-ChildItem -LiteralPath .\ -Recurse | Where-Object {
$_ -is [System.IO.FileInfo] `
-and (($_.Directory.Name -eq 'Single' `
-and $_.Length -gt (1*1024*1204)) `
-or ($_.Directory.Name -eq 'Multiple' `
-and $_.Length -gt (5*1024*1204)))
} | ForEach-Object {
$command = '"E:\Program Files (x86)\PDFtk Server\bin\pdftk.exe" "'+$_.FullName+'" dump_data | findstr NumberOfPages'
$output = iex "& $command"
$pages = $output.Substring(15,$output.length-15)
Write-Host $_.FullName '|' $pages
if((0+$pages) -gt 4){
#$openReader = '"C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" "'+$_.FullName+'"'
#iex "& $openReader"
$path = '"'+$_.FullName+'"'
Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -ArgumentList $path
}
}
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