-
Notifications
You must be signed in to change notification settings - Fork 0
/
00-Inventory-and-Page-Count-Recursive(PDF Only 7.3) [Code]
15 lines (15 loc) · 1.82 KB
/
00-Inventory-and-Page-Count-Recursive(PDF Only 7.3) [Code]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
;;;===,,,@echo off
;;;===,,,echo Inventory and Page Count V7.3 - By Cpl Nicholas COTTON. [email protected]
;;;===,,,echo This app will print a list of PDFs and their page count to "00-Inventory-and-Page-Count-[JOB TYPE].csv"
;;;===,,,echo Warning! This will not work for password encrypted PDFs. An error will be displayed.
;;;===,,,echo Warning! This app will only print the page count for the first document in a portfolio.
;;;===,,,echo Uses embedded PDFInfo v 4.3 from https://www.xpdfreader.com/, see https://github.com/nicholasgcotton/Inventory-and-Page-Count-CSV for more information.
;;;===,,,C:\Windows\System32\findstr.exe /v "^;;;===,,," "%~f0" > 00pdfinfo-extracted.exe
;;;===,,,echo -------------------Starting PowerShell -----------------------------------------------
;;;===,,,powershell -Command "$Root = $pwd.path; $INVOBJ = foreach($File in (Get-ChildItem -Path $Folder -Recurse -Filter *.pdf )){$Pages = (.\00pdfinfo-extracted $File.FullName | Select-String -Pattern '(?<=Pages:\s*)\d+').Matches.Value; [PSCustomObject]@{FileName = $File.Name; Pages = $Pages; Combined = '=CONCATENATE(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-2),\" (\",OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-1),IF(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-1)=0,\"Error getting \",\"\"),(IF(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-1)=1,\" page\",\" pages\")),\")\")'; RelativePath = $File.FullName.Substring($Root.Length+1);}};$INVOBJ | Sort-Object "RelativePath" | Export-Csv -NoTypeInformation -Path 00-Inventory-and-Page-Count-Recursive-PDF-Only.csv"
;;;===,,,echo -------------------Finished PowerShell -----------------------------------------------
;;;===,,,del 00pdfinfo-extracted.exe
;;;===,,,echo Review errors for non-PDF items or encrypted PDFs.
;;;===,,,echo Otherwise the program has completed successfully.
;;;===,,,pause
;;;===,,,exit /b