• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Dos .bat help

lokiju

Lifer
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?

 
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?
 
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
 
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.
 
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!
 
Back
Top