-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan.vbs
68 lines (60 loc) · 2.74 KB
/
scan.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'******************************************************************************
' File: scan.vbs
' Author: (c) M. Buttig
' Version: 1.0.1
'
' Description:
' ------------
' This vbs scripts takes the scanned TIFF image (single or multipage) which is
' passed as an argument. It creates a PDF file of that image with OCR into the
' same directory of the image. After creating the PDF file, it deletes the
' passed TIFF image.
'
' Version history:
' ----------------
' 1.0.0 - initial Version
' 1.0.1 - With configuring section
'
'******************************************************************************
Dim path_NAPS_Console_exe
Dim path_Dest_Dir_OcrPDF
Dim file_OcrPDF_Naming
' Configure section
' -----------------
path_NAPS_Console_exe = "C:\Program Files (x86)\NAPS2\NAPS2.Console.exe"
path_Dest_Dir_OcrPDF = "C:\Scans"
file_OcrPDF_Naming = "scan_$(YYYY)-$(MM)-$(DD)_$(hh)-$(mm)-$(ss).pdf"
' ^ ^ ^ ^ ^ ^
' | | | | | +-- Second
' | | | | +-- Minute
' | | | +--Hour
' | | +-- Day
' | +-- Month
' +-- Year
' End configure section, NO CHANGES FROM HERE
Dim argument
Dim cmd
Dim fso
if wscript.arguments.count > 0 then
argument = wscript.arguments(0)
end if
if Len(argument) > 0 then
'The command line has to be in the form ...
'cmd: NAPS2.Console -i %1 -n 0 -o "C:\Scans\scan_$(YYYY)-$(MM)-$(DD)_$(hh)-$(mm)-$(ss).pdf" --ocrlang "deu+eng"
'%1 is the argument which is passed to this script. This shoud be the
'scanned TIFF image.
cmd = """" & path_NAPS_Console_exe & """" & " -i " & """" & argument & """" & " --verbose -n 0 -o """ & path_Dest_Dir_OcrPDF & "\" & file_OcrPDF_Naming & """ --ocrlang ""deu+eng"""
set wshshell = CreateObject("WScript.Shell")
wshshell.run cmd, 1, True
'Delete source file
Set fso = CreateObject("Scripting.FileSystemObject") 'Calls the File System Object
fso.DeleteFile(argument) 'Deletes the file throught the DeleteFile function
else
WScript.Echo "The arguements you passed me are: " & argument
WScript.Echo "NAPS executable is set to: " & path_NAPS_Console_exe
WScript.Echo "path_Dest_Dir_OcrPDF: " & path_Dest_Dir_OcrPDF
WScript.Echo "file_OcrPDF_Naming: " & file_OcrPDF_Naming
WScript.Echo "----------------------------------"
WScript.Echo "Full execution command: " & """" & path_NAPS_Console_exe & """" & " -i " & """" & argument & """" & " --verbose -n 0 -o """ & path_Dest_Dir_OcrPDF & "\" & file_OcrPDF_Naming & """ --ocrlang ""deu+eng"""
end if
'*** End