--overwritemode

Top  Previous  Next

--overwritemode value

 

Sets the action to take if TwainSave detects that the image file specified in the -f parameter already exists.

 

The valid options for value are as follows:

 

value

Definition

1

Overwrite existing file

2

Exit TwainSave immediately without overwriting file.

3

Create a new file based on the existing file name and an increment number.

 

 

When acquiring images, there is a possibility that the file specified already exists.  If this is the case, there are three actions that TwainSave can take.

 

For --overwritemode 1, TwainSave will always overwrite the existing file without warning.

For --overwritemode 2, TwainSave will exit immediately with a return code of 12 and will not overwrite the existing file.

For --overwritemode 3, TwainSave will create an image file based on the original file name plus an incrementing suffix number.  The name of the new file will be of the following form:

 

originalName__nnnn.ext

 

where originalName is the original base name of the existing file.  The nnnn is an incrementing suffix starting from 0001.  The ext will be the same extension that the original file name has.

 

So for example, if the following TwainSave command is issued.

twainsave --filename test.bmp --overwritemode 3

 

and the file test.bmp already exists, then on a successful scan of a page, test__0001.bmp will be created instead of overwriting test.bmp.   If another page is scanned, then a file named test__0002.bmp will be created, etc.  The --overwritemode 3 is smart enough to detect if the new file name already exists, and if it does, increments the suffix by 1 in the file name until a unique file name can be created..

 

Note that --overwritemode 3 works for multi page and single page types.  For example:

twainsave --filename test.pdf --filetype pdf --multipage --overwritemode 3

 

will create a multipage PDF file called test__0001.pdf if the file test.pdf already exists.

 

The maximum number of unique file names created is 9,999.  To increase this number, use the --overwritemax option.

 

Default Setting:

The --overwritemode is set to 1 (always overwrite the existing file).