Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Time Stamp in a batch file?

Status
Not open for further replies.

RedSoxM3

IS-IT--Management
Mar 27, 2006
39
US
I have a simple "move" batch file. It is:

Move E:\Mercator6.7\cmgr\mmgr\staging\*.cpt E:\Mercator6.7\cmgr\mmgr\mail\


Does anyone know how to have the output file in the \mail folder have a datatime stamp on it?
 
You could do this in a map, but it could run so fast the OS can't provide a unique time stamp.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
You could use the Oracle or any database to provide you a unique number. Not sure if the performance degradation associated with hitting the database for every file move would be a concern here.
 
Using a map is prob best but something like this might work in a batch file....

set d_yy=%date:~10,4%
set d_mm=%date:~4,2%
set d_dd=%date:~7,2%
set t_hh=%time:~,2%
set t_mm=%time:~3,2%
set t_ss=%time:~6,2%
set DtTmStmp=%d_yy%%d_mm%%d_dd%%t_hh%%t_mm%%t_ss%
set FileOut=E:\Mercator6.7\cmgr\mmgr\mail\%DtTmStmp%mi.edi

copy E:\Mercator6.7\cmgr\mmgr\staging\*.cpt %FileOut%
 
Use the following in the batch file...

@for /f "Tokens=1-4 Delims=/ " %%a in ('date /t') do @for /f "Tokens=5-7 Delims=:. " %%d in ('echo. ^| time ^| findstr /i /v enter') do @SET datestamp=20%%c%%b%%a%%d%%e%%f

(all on one line) - the date/time stamp is then available as %datestamp%

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top