Menu

#233 Timed batch scanning for books

5.X
closed
nobody
None
5.3.2
Feature Request
Medium
N/A
2016-11-03
2016-11-02
dronsf
No

Scenario: book scanning.

Problem: when you scan a book you do 2 actions: 1. you shift the book on the scanner (left page - right page) and 2. you flip the book pages. Shifting the book and closing the lid takes say 3 seconds, picking the book up, flipping the page, positiong it and closing the lid takes say 10 seconds. So at the moment you must use the longest time and this is inefficient. You can save say 35% of the time. Now scanning a 300 pages book takes say 50 minutes, but this could be done in a little more than 30.

Solution: implement a special batch scanning use case for books with 2 timers: the first one times the shifting action, the second one times the flipping action.

Discussion

  • Ben Olden-Cooligan

    Maybe you could do this using NAPS2.Console? For example, create a windows batch file called scan_book.bat with the following contents to scan 300 pages:

    @echo off
    
    for /L %%i in (1,1,150) do (
      "C:\Program Files (x86)\NAPS2\NAPS2.Console" -o "$(n).jpg" -d 10000 -v
      "C:\Program Files (x86)\NAPS2\NAPS2.Console" -o "$(n).jpg" -d 3000 -v
    )
    
    pause
    

    Then you can import all those jpg files into NAPS2 and save them as PDF or whatever.

     
    • dronsf

      dronsf - 2016-11-02

      Just tried it, works like a charm! I didn't even know there was a command line interface! Thank you so much!

       
  • Ben Olden-Cooligan

    • status: open --> closed
     
  • Ben Olden-Cooligan

    I'm glad to hear it.

     
  • dronsf

    dronsf - 2016-11-03

    I have taken the liberty to expand your suggestion, and I've made a tiny batch script with minimal data validation for interactive usage. Maybe others will find it useful. Here it is:

    @echo off
    setlocal
    rem NAPS2.Console.exe path
    set naps="C:\Program Files (x86)\NAPS2\NAPS2.Console.exe"
    rem dafault profile
    set profile="bn300"
    rem dafault shift time
    set deftshift=3
    rem dafault flip time
    set deftflip=8
    rem verbosity
    set verbose=-v
    rem jpeg image quality
    set imagequality=85
    rem file format
    set fileformat=tif
    
    if "%~1%"=="" (
        set "dest=."
        goto askpages
    )
    
    if not exist "%~1%" (
        echo The specified destination folder does not exist!
        goto end
    )
    
    :setdestinationfolder
    set dest=%~1
    if %dest:~-1% == \ (
        set dest=%dest:~0,-1%
    )
    
    :askpages
    set /p pages= "Pages:"
    if "%pages%"=="" ( goto askpages )
    call :numeric %pages%
    if %ret% EQU 0 ( goto askpages )
    if %pages% EQU 0 ( goto end )
    
    if %pages% LSS 10 ( set "filename=$(n)" )
    if %pages% GEQ 10 if %pages% LSS 100 ( set "filename=$(nn)" )
    if %pages% GEQ 100 if %pages% LSS 1000 ( set "filename=$(nnn)" )
    if %pages% GEQ 1000 if %pages% LSS 10000 ( set "filename=$(nnnn)" )
    if %pages% GTR 10000 ( set "filename=$(n)" )
    
    set /a last=%pages% %% 2
    set /a half=%pages% / 2
    
    :asktshift
    set /p tshift= "Shift time:"
    if "%tshift%"=="" ( set /a tshift=%deftshift% )
    call :numeric %tshift%
    if %ret% EQU 0 ( goto asktshift )
    set /a tshift*=1000
    
    :asktflip
    set /p tflip= "Flip time:"
    if "%tflip%"=="" ( set /a tflip=%deftflip% )
    call :numeric %tflip%
    if %ret% EQU 0 ( goto asktflip )
    set /a tflip*=1000
    
    for /L %%i in (1,1,%half%) do (
        echo Flip...
        %naps% -o "%dest%\%filename%.%fileformat%" --jpegquality %imagequality% -p %profile% -d %tflip% %verbose%
        echo Shift...
        %naps% -o "%dest%\%filename%.%fileformat%" --jpegquality %imagequality% -p %profile% -d %tshift% %verbose%
    )
    
    if %last% EQU 0 (
        goto end
    ) else (
        echo Flip...
        %naps% -o "%dest%\%filename%.%fileformat%" --jpegquality %imagequality% -p %profile% -d %tflip% %verbose%
    )
    goto end
    
    :numeric
    echo %1%| findstr /xr "^[1-9][0-9]*$ ^00*$" >nul
    if %ERRORLEVEL% EQU 0 (
        set /a ret=1
    ) else (
        set /a ret=0
    )
    exit /B 0
    
    :end
    
    pause
    
     

Log in to post a comment.