Another CmdTwain Batch File Example

Here’s another batch file example. It includes the date and time in the filename of scanned files.

Aside from the benefit of keeping that useful information with the file, it also allows you to scan a bunch of pages without having to rename each file as you scan.

The “set datetimef=…” line controls the actual format of the datetime stamp. Some may wish to use “%year%-%month%-%day%T%hour%%min%%secs%”.

I personally use “%year%%month%%day%.%hour%%min%” in other projects; but only for consistency with a choice made long ago – the use of standard separators (as in the example) or an international format will make your life easier in the long run.

Thank you to Jonas Schmuttermair for providing the example. I hope many of you find it useful.

@echo off
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%

set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%

set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%

set year=%date:~-4%

set month=%date:~3,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%

set day=%date:~0,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%

set datetimef=%year%_%month%_%day%_%hour%_%min%_%secs%

cd %ProgramFiles(x86)%\GssEziSoft\cmdtwain

cmdtwain.exe C:\input\%datetimef%.jpg



The example provided here is free of charge but it is also without warranty of any kind. The user is responsible for determining its suitability or otherwise for their particular needs. Neither the authors, nor GssEziSoft, accept liability for any problems arising out of the use of the example program.

Download the Example

Right click and Save the example code.

Download CmdTwain

You can also download CmdTwain for free.

Leave a Reply

Your email address will not be published. Required fields are marked *