Developing Matt

My Technical Journal

batch-stamp current time and date

leave a comment »

Alas, I’ve broken my rule to not use batch. 

The way I create a file stamping the current date and time is as follows

@ECHO OFF
FOR /F "tokens=*" %%A IN (‘TIME/T’) DO SET Now=%%A
set strFile=%date:~10,4%%date:~4,2%%date:~7,2%_%Now%
set strFile=%strFile%
set strFile=%strFile::=%
set strFile=%strFile: =%
@ECHO ON

dir >>c:\%strFile%_CUSTOMgetfromsvn.txt

Assistance received from….

http://www.robvanderwoude.com/datetimentexamples.php

http://www.dostips.com/DtTipsStringManipulation.php

Advertisements

Written by matt

August 14, 2012 at 12:24 pm

Posted in Batch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: