how to calculate count of no.of pages in pdf file-batch file
Moderator: DosItHelp
Re: how to calculate count of no.of pages in pdf file-batch
damn....
Shall check for other way to count the pages.
Shall check for other way to count the pages.
Re: how to calculate count of no.of pages in pdf file-batch
The PDf was Created by QuarkXPress(R) 9.3
Maybe it's non-standard.
Maybe it's non-standard.
-
- Posts: 12
- Joined: 30 Aug 2014 10:55
Re: how to calculate count of no.of pages in pdf file-batch
ShadowThief wrote:sivasriram wrote:ShadowThief wrote:Code: Select all
@echo off
cls
set /p "file_name=File name: "
findstr /R /C:"/Type\s*/Page[^s]" "%file_name%"|find /c /v ""
the code was not working here
it is running fine, but output is not at all appearing...
Oh yeah, you wanted it output to a file, didn't you? Sorry about that...Code: Select all
@echo off
cls
set /p "file_name=File name: "
echo|set /p=%file_name%,>>pdf_num.csv
findstr /R /C:"/Type\s*/Page[^s]" "%file_name%"|find /c /v "">>pdf_num.csv
the above mentioned code is working fine but the csv file is generating count = 0
i m just replaing file name=22.pdf in the code.
am i doing correct please guide me
here is what m doing
set /p "22=22: "
22: echo|set /p=%file_name%,>>pdf_num.csv
findstr /R /C:"/Type\s*/Page[^s]" "%22.pdf%"|find /c /v "">>pdf_num.txt
FINDSTR: Cannot open %22.pdf%
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: how to calculate count of no.of pages in pdf file-batch
You just went through the code and replaced every instance of the string "file name" or "file_name" with 22.pdf, of course it's not going to work; you broke the code!
What the original code did was ask the user to type in the name of the file to get the page numbers for. You would have had to enter something like C:\Users\Joe\Documents\report.pdf.
if you want to store the file name in the code, you'd need something like
What the original code did was ask the user to type in the name of the file to get the page numbers for. You would have had to enter something like C:\Users\Joe\Documents\report.pdf.
if you want to store the file name in the code, you'd need something like
Code: Select all
@echo off
cls
set file_name=22.pdf
echo|set /p=%file_name%,>>pdf_num.csv
findstr /R /C:"/Type\s*/Page[^s]" "%file_name%"|find /c /v "">>pdf_num.csv
Re: how to calculate count of no.of pages in pdf file-batch
foxidrive wrote:The PDf was Created by QuarkXPress(R) 9.3
Maybe it's non-standard.
rather images are counted for pages where there are no pages.
I suppose the string "/Image/Type" or "/type/image" can be found around 44 times?
-
- Posts: 12
- Joined: 30 Aug 2014 10:55
Re: how to calculate count of no.of pages in pdf file-batch
ShadowThief wrote:You just went through the code and replaced every instance of the string "file name" or "file_name" with 22.pdf, of course it's not going to work; you broke the code!
What the original code did was ask the user to type in the name of the file to get the page numbers for. You would have had to enter something like C:\Users\Joe\Documents\report.pdf.
if you want to store the file name in the code, you'd need something likeCode: Select all
@echo off
cls
set file_name=22.pdf
echo|set /p=%file_name%,>>pdf_num.csv
findstr /R /C:"/Type\s*/Page[^s]" "%file_name%"|find /c /v "">>pdf_num.csv
this is what i tried mate
@echo off
cls
cd desktop\12
set file_name=22.pdf
echo|set /p=%file_name%,>>pdf_num.txt
findstr /R /C:"/Type\s*/Page[^s]" "%file_name%"|find /c /v "">>pdf_num.txt
and output is something like this
22.pdf, 0
the pdf contains 14 pages but count i m getting is 0 ?

plz help
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: how to calculate count of no.of pages in pdf file-batch
You will have to put the full path of the file if the batch file and the pdf aren't in the same folder.
Re: how to calculate count of no.of pages in pdf file-batch
npocmaka_ wrote:rather images are counted for pages where there are no pages.
I suppose the string "/Image/Type" or "/type/image" can be found around 44 times?
Yes, it has "/Image/Type/" 44 times, I think.
-
- Posts: 12
- Joined: 30 Aug 2014 10:55
Re: how to calculate count of no.of pages in pdf file-batch
ShadowThief wrote:You will have to put the full path of the file if the batch file and the pdf aren't in the same folder.
hey shadow see man my folder 12 containsa pdf file named 22.pdf(which is in desktop) i m running code through command prompt if it worked i would do a batch file, but the output is printing 0 every time mate .
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: how to calculate count of no.of pages in pdf file-batch
sivasriram wrote:ShadowThief wrote:You will have to put the full path of the file if the batch file and the pdf aren't in the same folder.
hey shadow see man my folder 12 containsa pdf file named 22.pdf(which is in desktop) i m running code through command prompt if it worked i would do a batch file, but the output is printing 0 every time mate .
And when you run the script and it asks for a file are you entering C:\Users\<whatever_your_username_is>\Desktop\12\22.pdf ?
Re: how to calculate count of no.of pages in pdf file-batch
ShadowThief wrote:And when you run the script
It does return 0 for several files and the number for some others.
-
- Posts: 12
- Joined: 30 Aug 2014 10:55
Re: how to calculate count of no.of pages in pdf file-batch
ShadowThief wrote:sivasriram wrote:ShadowThief wrote:You will have to put the full path of the file if the batch file and the pdf aren't in the same folder.
hey shadow see man my folder 12 containsa pdf file named 22.pdf(which is in desktop) i m running code through command prompt if it worked i would do a batch file, but the output is printing 0 every time mate .
And when you run the script and it asks for a file are you entering C:\Users\<whatever_your_username_is>\Desktop\12\22.pdf ?
this is what i tried now
@echo off
cls
set file_name=C:\Documents and Settings\Prudhvi\Desktop\12\22.pdf
echo|set /p=%file_name%,>>pdf_num.txt
findstr /R /C:"/Type\s*/Page[^s]" "%file_name%"|find /c /v "">>pdf_num.txt
echo|set /p=%file_name%,>>pdf_num.txt
no output nothing this time , even txt file not created in this case
Re: how to calculate count of no.of pages in pdf file-batch
Seems to work for me.
Code: Select all
C:\BatchFiles\PDFCount>dir /a-d /b
pdfcount.bat
ThreePageTest.pdf
C:\BatchFiles\PDFCount>pdfcount.bat
File name: ThreePageTest.pdf
C:\BatchFiles\PDFCount>dir /a-d /b
pdfcount.bat
pdf_num.csv
ThreePageTest.pdf
C:\BatchFiles\PDFCount>type pdf_num.csv
ThreePageTest.pdf, 3
C:\BatchFiles\PDFCount>
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: how to calculate count of no.of pages in pdf file-batch
sivasriram wrote:no output nothing this time , even txt file not created in this case
Try this. If the path has spaces in it, the whole thing needs to be surrounded by double quotes.
Code: Select all
@echo off
cls
set file_name="C:\Documents and Settings\Prudhvi\Desktop\12\22.pdf"
echo|set /p=%file_name%,>>pdf_num.txt
findstr /R /C:"/Type\s*/Page[^s]" "%file_name%"|find /c /v "">>pdf_num.txt
Re: how to calculate count of no.of pages in pdf file-batch
foxidrive wrote:list of pdf files
That is some interesting reading material.