Menu

#679 Batch OCR PDF Files

6.X
open
nobody
None
6.1.2.25834
Support
Medium
WIA
2019-12-27
2019-11-07
Todd Avery
No

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.

Discussion

  • Karl Mueller

    Karl Mueller - 2019-12-06

    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.

     
  • Todd Avery

    Todd Avery - 2019-12-06

    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
  • Karl Mueller

    Karl Mueller - 2019-12-07

    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.

     
  • Todd Avery

    Todd Avery - 2019-12-08

    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.

     
  • Karl Mueller

    Karl Mueller - 2019-12-08

    Sorry, somehow the formating removed the \ between Scans and the rest.

    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
    

    --> 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
  • Todd Avery

    Todd Avery - 2019-12-09

    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?

     
  • Todd Avery

    Todd Avery - 2019-12-09

    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.

     
  • Karl Mueller

    Karl Mueller - 2019-12-09

    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)

     
  • Todd Avery

    Todd Avery - 2019-12-10

    Here is a screenshot of the cmd window.

     
  • Karl Mueller

    Karl Mueller - 2019-12-10

    have you pasted the code into an empty text file and renamed the file from .txt to .bat?

     
  • Todd Avery

    Todd Avery - 2019-12-11

    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?

    cd C:\Program Files (x86)\NAPS2\
    for /R %%i in (\nas1\home\Scans\*.pdf) do naps2.console -i %%i -o %%i --enableocr --force -n 0
    pause
    
     
  • Karl Mueller

    Karl Mueller - 2019-12-12

    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:

    \\nas1\home\Scans\*.pdf
    

    I think the caht here removed the double backslash.

     
  • Todd Avery

    Todd Avery - 2019-12-13

    Would it be better or easier to do it through a network drive? Say Drive U:

     
  • Karl Mueller

    Karl Mueller - 2019-12-13

    You can try, but it should work with any path that works in windows explorer

     
  • Todd Avery

    Todd Avery - 2019-12-26

    It must not like me. I can't get it to work for the life of me.

     
  • Karl Mueller

    Karl Mueller - 2019-12-26

    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.

     
  • Todd Avery

    Todd Avery - 2019-12-27

    So it looks like it dosn't like spaces in file name.

     

Log in to post a comment.