Created
February 12, 2019 21:34
-
-
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.
This file contains hidden or 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
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