Execution from the Command Line
You can run FileMasker as a batch process from the command line as described below for Windows and Linux/Unix environments.
The FileMaskerLib.jar Executable File
The executable Java file is found in the unzipped FileMasker software location filemasker/modules/ext/FileMaskerLib.jar
Do not rename, move or delete FileMaskerLib.jar because the GUI also relies on this file being exactly where it is.
If you like, you can copy FileMaskerLib.jar to another location. This file can be run from the command line independently of all of the other delivered FileMasker files.
Syntax
The syntax to run FileMasker from the command line is:
java -cp <FileMaskerLib.jar-path> com.filemasker.lib.main.FileMasker <project-spec> [<project-overrides>] [<options>]
Where
<FileMaskerLib.jar-path> is the path to the FileMaskerLib.jar file.
<project-spec> specifies the path to the FileMasker project to be executed:
PROJECT=<project-file-path>
<project-overrides> are parameters defined in the project that are to be overridden, such as input and out file locations, file format options, etc. Multiple overrides are separated by spaces:
INFILE=<input-file-path> overrides the input file location defined within the project file.
FORMAT={CSV|JSON}
OUTMODE={DIRECTORY|FILEPATH|REPLACE}
DIRECTORY output file should be placed in the directory specified in project or use the OUTDIR override if specified.
FILEPATH output file should be placed in the path specified in project or use the OUTFILE override if specified.
REPLACE input file shall be replaced with the output file.
OUTDIR=<output-dir-path> overrides the output directory path defined within the project file. Used only if OUTMODE (project or override) is DIRECTORY.
OUTFILE=<output-file-path> overrides the output file path defined within the project file. Used only if OUTMODE (project or override) is FILEPATH.
ADJUST_OUTFILE_EXT={TRUE|FALSE} adjusts file extension to correctly indicate compression used (if any) in outfile. Used only if OUTMODE (project or override) is DIRECTORY.
OVERWRITE={TRUE|FALSE} overrides project setting for whether to overwrite output file if it already exists. Used only if OUTMODE (project or override) is DIRECTORY or FILEPATH.
INCOMPRESSION={NONE|FILE_EXTENSION|GZIP} overrides project setting for input file compression
OUTCOMPRESSION={NONE|AS_INPUT|GZIP} overrides project setting for output file compression
OVERWRITE={TRUE|FALSE} overrides project setting for whether to overwrite
CSV_HEADER={TRUE|FALSE} overrides project setting for whether input CSV file has a header row present.
CSV_QUOTE=<quote-char> overrides project setting for character to be used as CSV quote character. Specify a single character only.
CSV_SEPARATOR=<separator-char> overrides project setting for character to be used as CSV separator character. Specify a single character only. You can specify the actual character or use the method described in How to Specify an Unprintable Character.
CSV_WRITEQUOTES={ALWAYS|AS_NEEDED|NEVER} overrides project setting for whether input CSV file has a header row present.
JSON_LAYOUT={NORMAL|NOROOTARRAY} overrides project setting for JSON file layout. The layouts are explained in File Formats.
<options> define FileMasker operational parameters such as license location, log location and whether to create non-existent directories.
KEY=<project-key> specifies the project key.
LICENSE=<license-file-path> overrides the environment's preference setting (set in GUI) for FileMasker license path.
LOG=<log-file-path>[!] specifies text file location where log messages are to be written. If <log-file-path> already exists and ! is specified then the location shall be overwritten otherwise the log messages shall be appended.
Example:
java -cp ./FileMaskerLib.jar com.filemasker.lib.main.FileMasker project=K:/FileMasker/mydemo/proj.fmp key=MySecretTextKey81309
Example:
java -cp ./FileMaskerLib.jar com.filemasker.lib.main.FileMasker "project=K:/FileMasker/demo projects/proj_x3.fmp" "key=aRc809.80Y kha"
Quotes are specified around the entire PROJECT and KEY parameters because their values contains embedded spaces. Otherwise the quotes are optional.
Demo Files
Complete command line sample files have been included with the delivered software. You can find them in the directory filemasker/demo. Please refer to the README.txt in that directory for an explanation of each file.
How to Specify an Unprintable Character
FileMasker provides a convenient platform-independent method of specifying an unprintable or non-visible characters that may otherwise be problematic to specify for FileMasker command line parameters in batch files. For example, specifying the TAB character for CSV_SEPARATOR in Windows batch files.
FileMasker will recognize the following escape sequences listed below:
\b Backspace
\f Formfeed
\n Newline
\r Carriage return
\t Tab
\v Vertical tab
FileMasker will also recognize a character specified as a hexadecimal number code specified as \0x<hex-number>.
Example: The Carriage return character could be specified in hexadecimal format as \0xD or \0x0D
Example: CSV_SEPARATOR=\t or CSV_SEPARATOR =\0x9
FileMasker will also recognize a character specified as a decimal number code specified as \<decimal-number>.
Example: The Carriage return character could be specified in decimal format as \13
Example: CSV_SEPARATOR=\t or CSV_SEPARATOR =\9
|