Skip to main content
Participating Frequently
April 3, 2021
해결됨

Batch process to check hundreds of pdfs to see if they are not "image-only" PDFs

  • April 3, 2021
  • 1 답변
  • 3525 조회

How can I check all pdfs in several directories/folders to ensure that they are not just "scanned or image-only" pdfs and if any are found, create a report (html file or a text file) with the results.

I understand how to do this with the pdf that I open in Adobe DC but no idea how to do this with actions/scripting etc.

이 주제는 답변이 닫혔습니다.
최고의 답변: try67

You can do it using JavaScript by counting the number of words in the file. If it's zero, it means it hasn't been OCRed.

The easiest way to output these results is to the JS Console, which you can then open at the end of the process to see the names of the files that were detected.

You can do that by having your Action execute this code:

 

var totalNumWords = 0;
for (var p=0; p<this.numPages; p++) {
	var numWords = this.getPageNumWords(p);
	totalNumWords+=numWords;
	if (totalNumWords>0) break;
}
if (totalNumWords==0) console.println(this.path);

1 답변

try67
Community Expert
try67Community Expert답변
Community Expert
April 3, 2021

You can do it using JavaScript by counting the number of words in the file. If it's zero, it means it hasn't been OCRed.

The easiest way to output these results is to the JS Console, which you can then open at the end of the process to see the names of the files that were detected.

You can do that by having your Action execute this code:

 

var totalNumWords = 0;
for (var p=0; p<this.numPages; p++) {
	var numWords = this.getPageNumWords(p);
	totalNumWords+=numWords;
	if (totalNumWords>0) break;
}
if (totalNumWords==0) console.println(this.path);
Jerry5EFC작성자
Participating Frequently
April 3, 2021

Thank you.....I guess what I am trying to do can be done, now just need to understand how to actually do it with the information you provided (never created an action before or even used javascript in Adobe DC).

 

Is there anyplace that would explain (sort of a step by step) how to do something like you recommended?

 

BTW - thank you for replying.

Jerry5EFC작성자
Participating Frequently
April 3, 2021

You need to create a new Action via Tools - Action Wizard, add to it an Execute JavaScript command and then paste the code into that command.

Untick the "Prompt User" check-box under this command, save the Action, and then run it on your files or folder.

When it's done press Ctrl-J to open the JS Console and the output (if any) will be visible there.


Wow....and thank you. It works just like you said. 

 

One last beginner question....how would I modify the javascript so that it only searches pdf files (we have lots of other file types in the various folders/directors) and excludes all other file types/extensions?