Command Line Usage

Back to Support

Overview

NAPS2, in addition to the primary GUI, also offers a command-line interface (CLI) via the NAPS2.Console.exe program. This allows scanning and saving documents to be automated and/or scripted.

Usage

NAPS2.Console uses standard unix-style options. Each option has a long form (e.g. "--output"), and some have a short form (e.g. "-o"). Some options are flags, and some are expected to be provided a value.

Required Options

At least one of these options must be specified.

-o, --output {path}
Specifies the path, name, and extension of the output file to save. The extension determines the output type (e.g. ".pdf" for a PDF file, ".jpg" for a JPEG image, etc.).

naps2.console -o "F:\scanned receipt.pdf"

-e, --email {filename}
Specifies that an email should be sent with the scan attached with the given file name and extension. The extension determines the attachment type (e.g. ".pdf" for a PDF file, ".jpg" for a JPEG image, etc.).

naps2.console -e "scan.pdf"

-a, --autosave
Specifies that the Auto Save settings from the selected profile should be used. The profile must have Auto Save enabled.

naps2.console -a

Import Options

-i, --import {filenames}
Specifies the name and path of one or more pdf/image files to import. Imported files are prepended to the output in the order they are specified. Multiple files are separated by a semicolon (";").

naps2.console -i "F:\incomplete scan.pdf" -o "F:\complete scan.pdf"

--importpassword {password}
Specifies the password to be used to import any encrypted PDFs.

naps2.console -i "F:\encrypted.pdf" --importpassword "123456" -o "F:\complete scan.pdf"

Combining and Converting Files

The -i/--import option can be used in combination with the option "-n 0" to combine multiple files together or to change the type of a file without doing any scanning.

To combine multiple images into a PDF:

naps2.console -i "F:\a.jpg;F:\b.jpg;F:\c.jpg" -n 0 -o "F:\abc.pdf"

To combine multiple PDFs together:

naps2.console -i "F:\a.pdf;F:\b.pdf;F:\c.pdf" -n 0 -o "F:\abc.pdf"

To convert a TIFF into a PDF:

naps2.console -i "F:\a.tiff" -n 0 -o "F:\a.pdf"

To convert between image types:

naps2.console -i "F:\a.png" -n 0 -o "F:\a.jpg"

PDF Options

These options are only applicable if the output file is a PDF.

--pdftitle {title}
Specifies the title for generated PDF metadata.

--pdfauthor {author}
Specifies the author for generated PDF metadata.

--pdfsubject {subject}
Specifies the subject for generated PDF metadata.

--pdfkeywords {keywords}
Specifies the keywords for generated PDF metadata.

naps2.console -o "F:\scan.pdf" --pdftitle "January Receipts" --pdfauthor "John Smith" --pdfsubject "Receipts" --pdfkeywords "January, Receipts"

--usesavedmetadata
Specifies that the metadata configured in the GUI should be used for generated PDF.

naps2.console -o "F:\scan.pdf" --usesavedmetadata

--encryptconfig {path}
Specifies the name and path of an XML file to configure encryption for the generated PDF.

naps2.console -o "F:\encrypted.pdf" --encryptconfig "F:\pdfencryption.xml"
pdfencryption.xml:
<?xml version="1.0"?>
<PdfEncryption xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <EncryptPdf>true</EncryptPdf>
  <UserPassword>123</UserPassword>
  <OwnerPassword>456</OwnerPassword>
  <AllowContentCopyingForAccessibility>false</AllowContentCopyingForAccessibility>
  <AllowAnnotations>false</AllowAnnotations>
  <AllowDocumentAssembly>false</AllowDocumentAssembly>
  <AllowContentCopying>false</AllowContentCopying>
  <AllowFormFilling>false</AllowFormFilling>
  <AllowFullQualityPrinting>false</AllowFullQualityPrinting>
  <AllowDocumentModification>false</AllowDocumentModification>
  <AllowPrinting>false</AllowPrinting>
</PdfEncryption>

--usesavedencryptconfig
Specifies that the encryption configured in the GUI should be used for the generated PDF.

naps2.console -o "F:\encrypted.pdf" --usesavedencryptconfig

Image Options

--jpegquality {#}
(Default: 75) Specifies the quality of saved JPEG files (0-100).

naps2.console -o "F:\scan.jpg" --jpegquality 90

Email Options

These options are only applicable if -e/--email is specified.

--to {address}
Specifies one or more addresses (comma-separated) of the email recipients.

--cc {address}
Specifies one or more addresses (comma-separated) of the email recipients.

--bcc {address}
Specifies one or more addresses (comma-separated) of the email recipients.

--subject {subject}
Specifies the subject of the email message.

--body {text}
Specifies the body text of the email message.

--autosend
Specifies that the email should be sent without prompting the user to edit it first. Note that Outlook may not allow the email to be sent without user approval.

--silentsend
Requires --autosend. Specifies that the user should not be prompted to authenticate. This may result in an error if authentication is required. Note that Outlook may not allow the email to be sent without user approval.

naps2.console -e "scan.pdf" --to "jsmith@example.com" --subject "Scanned Document" --body "Here it is." --autosend --silentsend

OCR Options

If OCR options aren't specified, the options from the GUI are used.

--ocrlang {code}
Specifies the three-letter code for the language used for OCR (e.g. 'eng' for English, 'fra' for French, etc.). Multiple codes can be separated by the '+' symbol. Implies --enableocr. Reference: http://www.loc.gov/standards/iso639-2/php/code_list.php

naps2.console -o "F:\scan.pdf" --ocrlang "eng"

--enableocr
Specifies that OCR should be used when generating PDFs.

naps2.console -o "F:\scan.pdf" --enableocr

--disableocr
Specifies that OCR should NOT be used when generating PDFs. Overrides --enableocr.

naps2.console -o "F:\scan.pdf" --disableocr

Order Options

--interleave
Specifies that pages should be interleaved. For example, if you scan pages in the order "1, 3, 5, 2, 4, 6", using this option will result in the order "1, 2, 3, 4, 5, 6".

--altinterleave
Specifies that pages should be interleaved in an alternative way. For example, if you scan pages in the order "1, 3, 5, 6, 4, 2", using this option will result in the order "1, 2, 3, 4, 5, 6".

--deinterleave
Specifies that pages should be deinterleaved. For example, if you have pages in the order "1, 4, 2, 5, 3, 6", using this option will result in the order "1, 2, 3, 4, 5, 6".

--altdeinterleave
Specifies that pages should be deinterleaved in an alternative way. For example, if you have pages in the order "1, 6, 2, 5, 3, 4", using this option will result in the order "1, 2, 3, 4, 5, 6".

--reverse
Specifies that pages should be reversed. For example, if you scan pages in the order "6, 5, 4, 3, 2, 1", using this option will result in the order "1, 2, 3, 4, 5, 6".

Other Options

-p, --profile {name}
Specifies the name of the profile to use when scanning. Profiles are defined using the GUI. If this option is not specified, the most-recently-used profile from the GUI is selected.

naps2.console -o "F:\scanned receipt.pdf" -p "Canon MP495 (color)"

-v, --verbose
Displays progress information. If not specified, no output will be displayed upon success.

naps2.console -o "F:\scanned receipt.pdf" -v

-n, --number {#}
(Default: 1) The number of scans to perform. This may be different from the number of pages scanned (e.g. if you have an automated document feeder).

naps2.console -o "F:\scanned receipts.pdf" -n 5

-d, --delay {#}
(Default: 0) The delay (in milliseconds) between each scan.

naps2.console -o "F:\scanned receipts.pdf" -n 5 -d 5000

-f, --force
Overwrite existing files. If not specified, any files that already exist will not be changed (and an error message will be displayed).

naps2.console -o "F:\scanned receipt.pdf" -f

-w, --wait
After finishing, wait for user input (enter/return) before exiting.

naps2.console -o "F:\scanned receipt.pdf" -w

--help
Display a help screen similar to this wiki page.

naps2.console --help

Placeholders

Any path arguments (-o, -e, etc.) as well as some text arguments (--subject, --body) can use placeholders. The following placeholders are available:

$(YYYY) - The current year.
$(YY) - The current year (00-99).
$(MM) - The current month (01-12).
$(DD) - The current day (01-31).
$(hh) - The current hour (00-23).
$(mm) - The current minute (00-59).
$(ss) - The current second (00-59).
$(nnnn) - A unique incrementing number (0001, 0002, etc.).
$(nnn) - A unique incrementing number (001, 002, etc.).
$(nn) - A unique incrementing number (01, 02, etc.).
$(n) - A unique incrementing number (1, 2, etc.).

Back to Support