Batch OCR PDF Files
Scan documents to PDF and other file types, as simply as possible.
Brought to you by:
ben-cyanfish
This is an awesome product and I now use it to scan all documents and perform OCR before saving. But now I am trying to play cathcup and perform OCR on files from the past several years. I know there is a way to import one document (PDF) at a time and run OCR then save the document. Is there a way to do a batch of PDF files in a folder and it just save over the existing file with it updated with OCR? Requring no user interaction other than to specify the folder and click start.
cd C:\Program Files (x86)\NAPS2\
for %%i in (folder*.pdf) do naps2.console -i %%i -o %%i --enableocr --force -n 0
pause
save as a .bat file --> done :)
Setup OCR via GUI first.
Thanks for the information. However, how do I tell it what folder or files to start scanning? Also will it scan sub folders? i essentially want to scan all folders in my home network drive.
Last edit: Todd Avery 2019-12-06
If you want subfolders aswell use "for /R %%"
replace the folder with you top level folder (your homedrive) for me it looks like this:
for /R %%i in (\Fritz.nas\fritz.nas\Scans*.pdf)
--> will process all files in the folder and subfolders.
Where you put Scans*.pdf, does that mean it will only do files that have Scans as the beginning of the filename and the * is wildcard for any characters after the word Scans? The reason I ask is because all my PDFs are names differently depending on what they are about. i.e. "2010-12-01 ATT Bill.pdf"
This is what I think my bat file will be:
cd C:\Program Files (x86)\NAPS2\
for /R %%i in (\nas\home\Scans*.pdf) do naps2.console -i %%i -o %%i --enableocr --force -n 0
pause
Lastly, does it matter where the bat file is placed at? Does it need to be inthe NAPS2 folder?
Thanks for your help.
Sorry, somehow the formating removed the \ between Scans and the rest.
--> Doesn't mater where you place it because the fist line will switch to your NAPS2 folder. So you have to change it if it's installed somewhere else.
If you don't want to overwrite you can adjust also the -o parameter.
Last edit: Karl Mueller 2019-12-08
Thank you. Is there a manual or something that has all the commands so I don't have to keep bothering you with all this?
Also, how do I know if it worked? I ran it and it just showed the command prompt with the entire script and then that was it. It took maybe 2 seconds.
Did you save it as a .bat file? It should run for each filoe and at the end prompt for a key to close it.
I'm using it frequently since I scan via network from my brotehr scaner. So I already get pdf files but now I use it to make the text searchable.
Basicaly it creating your own batch file (https://en.wikipedia.org/wiki/Batch_file) and then excecuting the commands of the naps2.console (https://www.naps2.com/doc-command-line.html)
Here is a screenshot of the cmd window.
have you pasted the code into an empty text file and renamed the file from .txt to .bat?
Yes, its in a notepad file that I named NASP2.bat. The exact code is below. Also wouldn't I need to have \nas1 rather than \nas1?
I'm not an expert in bat programming but I used the path from the windows explorer and it works well.
I would try this path:
I think the caht here removed the double backslash.
Would it be better or easier to do it through a network drive? Say Drive U:
You can try, but it should work with any path that works in windows explorer
It must not like me. I can't get it to work for the life of me.
I've uploaded my file her: https://drive.google.com/open?id=1SncobqtnC_FY6qDRn6_yWHnj9dPO9ZeD
Maybe it works if you take that and just replace the folder. it's nor recursive tho so subfolders will not be scanned.
So it looks like it dosn't like spaces in file name.