Home
»
Discussion Forums
»
z Old Forum - Archive
»
Date/Time Stamp
Subscribe via RSS
Share this
Similar Posts
Script to generate a date and time stamp for naming files
by
LegacyPoster
on
Sep 29, 2007
Monitor if File Date/Time Stamp Changing
by
LegacyPoster
on
Sep 21, 2009
Log Parser Date Stamp
by
Brandon
on
Jan 5, 2015
Agent Time stamping confusion
by
roba0665
on
Apr 18, 2011
Time stamps in LiveConnect suddenly in UTC
by
Lars M. Hansen
on
May 10, 2012
Not Answered
View More
Details
1
Reply
0
Subscribers
Posted
over 13 years ago
z Old Forum - Archive
Date/Time Stamp
Posted by
LegacyPoster
on
Apr 17, 2007 7:50 PM
Anyone figure out how to create a variable for a date/time stamp?
I need to create a file with the date/time in the file name. I tried ussing the %DATE% variable from inside a shell command but has slashes (/) between the day/month/year and therefor crestes a folder for each date.
Any help is appreciated! Example of filename neededis:
041607filename.txt
Legacy Forum Name: Date/Time Stamp,
Legacy Posted By Username: rage
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Apr 17, 2007 7:50 PM
It takes a few commands but you can do it this way:
DATE /T > date.txt
FOR /F "tokens=2,3* delims=/ " %i in (date.txt) do @ECHO %i%j%k > shortdate.txt
the date format will output as 04172007
then just read the "shortdate.txt" into a variable.
Keep in mind that when you use these commands in a K script that you have to enter double > since they are an escape character for them. I left them as they are so you can just paste those lines into a DOS window and see what the result is. You can do a "type date.txt" and a "type shortdate.txt"to see the contents of the files. If you want to know what I did in the FOR statement, just type "FOR /?" and read through the help. It is an extremely useful command.
Hope that helps.
--Brian
Legacy Forum Name: Script Requests,
Legacy Posted By Username: byulke
You have posted to a forum that requires a moderator to approve posts before they are publicly available.