Icon of Usage Cmmand line

ScannerTrimmer Usage Cmmand line

Usage Command line

You can change the behavior and settings of ScannerTrimmer by command line arguments. For example, you can use '/hide' command line switch to avoid showing ScannerTrimmer's main window and run as a command line application.

Run from 'Command Shell'

If you want to run ScannerTrimmer.exe from 'Command Shell' with /hide, please use Start to wait ScannerTrimmer.exe ends with /wait option. If you run ScannerTrimmer.exe directry, to reply for query to overwrite files will be difficut.

start /wait ScannerTrimmer.exe /hide /empty:empty.bmp sample.bmp
e.g. Run ScannerTrimmer.exe by Start with /wait option

Run from batch file (*.bat)

If you call ScannerTrimmer.exe in batch file, you can run ScannerTrimmer.exe directry (without Start). Because the command line arguments are limeted by character length, it is recomended to change current directory to the folder with input files before, and call ScannerTrimmer.exe with relatively short input pathes.

@echo off
set _EXE=X:\Original\cpp\ScannerTrimmer\ScannerTrimmer\Debug\ScannerTrimmer.exe
pushd "X:\Original\cpp\ScannerTrimmer\test\small"
 
if not "%ERRORLEVEL%" == "0" (
  exit /B
)

%_EXE% /hide /yes /empty:empty.bmp ayanami.bmp 2>err.txt

if not "%ERRORLEVEL%" == "0" (
  echo Error! refer to err.txt
)

popd
pause
Sample batch file (sample.bat)

pushd can change the current directory like cd /d , and popd can be restore the current directory by calling after. Incidentally, /d in cd /d is the option to enable cd to change the drive. The error message is written to the file 'err.txt' by 2>err.txt . And output files are overwritten without query with /yes option.

Run from VB Script (*.vbs)

It's a sample file to call ScannerTrimmer.exe in VB Script. You must change the variables: exePath, folder, emptyFile, files to fit your embironment. In the example, /reset option is not set and only use /empty option for settings, the other settings can be set by main window to call ScannerTrimmer.exe without /hide option previously.

Option Explicit

Dim exePath
exePath = "X:\Original\cpp\ScannerTrimmer\ScannerTrimmer\Debug\ScannerTrimmer.exe"
Dim folder
folder = "X:\Original\cpp\ScannerTrimmer\test\small"

Dim emptyFile
emptyFile = "empty.bmp"

Dim files
Set files = CreateObject("System.Collections.ArrayList")
files.add("ayanami.bmp")

Dim wsh
Set wsh = Wscript.CreateObject("Wscript.Shell")
Dim fso
Set fso = WScript.CreateObject("Scripting.FileSystemObject")

If fso.FolderExists(folder) Then

  wsh.CurrentDirectory = folder

  Dim cmdLine
  cmdLine = "2>err.txt"
  AppendArg cmdLine, exePath
  AppendArg cmdLine, "/hide"
  AppendArg cmdLine, "/yes"
  AppendArg cmdLine, "/empty:" & emptyFile
  Dim file
  For Each file in files
    AppendArg cmdLine, file
  Next

  Dim ret
  ret = wsh.Run("%comspec% /c " & chr(34) & cmdLine & chr(34), 1, True)

  If ret <> 0 Then
    WScript.Echo "Error! refer to err.txt: " & ret
  End If
  
Else
  
  WScript.Echo "Folder not found: " & folder
  
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub AppendArg(cmdLine, arg)
  If cmdLine = "" Then
    cmdLine = Chr(34) & arg & Chr(34)
  Else
    cmdLine = cmdLine & " " & Chr(34) & arg & Chr(34)
  End If
End Sub


Sample VB Script file (sample.vbs)

Chr(34) means double-quote "

Command line options

Options for change settings

/reset

Set the all settings *1 to default. /reset opion must be specified as the first argument *2.

*1 Except history of empty-image and save location.
*2 Specifying /reset as 2nd or after argument causes error.

ex1) ScannerTrimmer.exe /reset
ex2) ScannerTrimmer.exe "/reset"

/empty:

Specify 'Empty-image path scanned with no manuscript' after the colon.

ex1) ScannerTrimmer.exe /empty:"empty.bmp"
ex2) ScannerTrimmer.exe "/empty:empty.bmp"

/cut:

Specify 'Edges for trim' after the colon. You can change the option value except auto. For example, tlbr and ltrb has same meanings.

auto
auto
ltrb
left, top, right, bottom
rb
right, bottom
lt
left, top
rt
right, top
lb
left, bottom
lr
left, right
tb
top, bottom
l
left
r
right
t
top
b
bottom
ltb
left, top, bottom
rtb
right, top, bottom
ltb+
left, top, bottom/right, top, bottom
rtb+
right, top, bottom/left, top, bottom
ex1) ScannerTrimmer.exe /cut:auto
ex2) ScannerTrimmer.exe /cut:ltrb

/rotate:

Specify 'Edge for automatic rotation' after the colon.

none
no rotate
auto
auto
l
left side
r
right side
t
top side
b
bottom side
lr
left/right alternate
rl
right/left alternate
tb
top/bottom alternate
bt
bottom/top alternate
ex1) ScannerTrimmer.exe /rotate:auto
ex2) ScannerTrimmer.exe /rotate:lr

/deep_cut:

Specify 'Prior to cutting edges than keeping manuscript' after the colon.

on
Checked
off
Not checked
ex1) ScannerTrimmer.exe /deep_cut:on
ex2) ScannerTrimmer.exe /deep_cut:off

/size:

Specify 'Output size' after the colon.

off
Not checked
x,y
(x, y) is output size (Checked)
ex2) ScannerTrimmer.exe /size:off
ex1) ScannerTrimmer.exe /size:640,480

/trim:

Specify Trimming size after the colon.

off
Not checked
x,y
x, y is Vertical and Horizontal size (Checked)
ex2) ScannerTrimmer.exe /trim:off
ex1) ScannerTrimmer.exe /trim:4,4

/out:

Specify subfolder's name of save location after the colon.

ex) ScannerTrimmer.exe /out:trim

/format:

Specify 'Save image type' after the colon. Image type string is case insensitive.

jpeg,x
JPEG, and Quality is x
jpg,x
JPEG, and Quality is x
jpeg
JPEG
jpg
JPEG
bmp
BMP
png
PNG
tif
TIFF
tiff
TIFF
ex1) ScannerTrimmer.exe /format:jpeg,90
ex2) ScannerTrimmer.exe /format:PNG

/thread:

Specify 'Threads' after the colon.

ex1) ScannerTrimmer.exe /thread:1
ex2) ScannerTrimmer.exe /thread:4

Options for change behavior

file pathes

You can specify file pathes to process immediately as command line arguments begin with no '/'. If you want to exit the application after the processing, use /end or /hide option besides pathes.

ex1) ScannerTrimmer.exe a.bmp b.bmp
ex2) ScannerTrimmer.exe /end a.bmp b.bmp

/end

Specify /end to exit application automatically after processing initial pathes specified by command line arguments.

ex) ScannerTrimmer.exe /end a.bmp b.bmp

/hide

Specify /hide to exit application automatically after processing initial pathes specified by command line arguments. Unlike the /end ScannerTrimmer's main window is not shown and error messages are output to standard error output (stderr), and normal messages are output to standard output (stdout) and you must replay the query for overwriting output pathes by standard input (stdin).

ex1) ScannerTrimmer.exe /hide a.bmp b.bmp
ex2) ScannerTrimmer.exe /hide /yes a.bmp b.bmp

/yes

If you want to overwrite output image files without query, use this option /yes. This option affects both initial execution of pathes specified by command line arguments and interactive execution by dropping files.

ex) ScannerTrimmer.exe /hide /yes a.bmp b.bmp

Download

This software is a shareware, so only trial use is permitted with no fee. Please purchase if you use this software in practice.

DOWNLOAD FREE

Contact

Use mail form to contact me.

Share