Dos .bat help

lokiju

Lifer
May 29, 2003
18,526
5
0
I'm looking for a way in DOS to do a command to output a txt file in a location of my choice that displays as "yymmdd_hhmmss.txt" where yymmdd_hhmmss is whatever is the current year, month, day, hour, min, second.

It's something I want to append to the end of a .bat file that runs so I can have a log of what is actively happening in that .bat file.

Any pointers?

 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
I could write a program in C for you that'll do exactly what you need in a few hours when I get out of my exam, if you want?
 

WannaFly

Platinum Member
Jan 14, 2003
2,811
1
0
set var=""
set var2=""
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do set var=%%e%%f%%g
for /f "tokens=1-5 delims=:" %%d in ("%time%") do set var2=%%d%%e
rename testfile.test %var%%var2%.txt


The above will rename testfile.test to MMDDYYYYhhmm.txt
 

lokiju

Lifer
May 29, 2003
18,526
5
0
Originally posted by: WannaFly
set var=""
set var2=""
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do set var=%%e%%f%%g
for /f "tokens=1-5 delims=:" %%d in ("%time%") do set var2=%%d%%e
rename testfile.test %var%%var2%.txt


The above will rename testfile.test to MMDDYYYYhhmm.txt

I was able to get this working with the following layout

But I'm not to sure how to then get the .bat that I'm running to append a copy of whats happening to that newly created text file.

For more detail on what I'm trying to accomplish and why... I run a .bat that in turn runs a bunch of jobs that all run in dos, these jobs can take hours on end to complete and all the while there is useful information I'd like to see for these jobs but have no way of seeing that information since these jobs are kicked off in the middle of the night with a scheduled task. The only way I can see what is on the screen at a given moment is if I run the .bat while actively logged into the server.
 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
So let me get this straight... You want the output of your DOS program to be sent to some text file, where the name of the text file is a timestamp? So that later, you can look at all the text files and read what the output was?

edit: Here you go!