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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File

Status
Not open for further replies.

sham14

MIS
May 14, 2003
42
NL
I am writing a batch file and sending results to a file. I do not want the file overwritten everytime that i run it but i do want a seperate file for each time it is run so i am looking somehow to put some variable into the file name (for example time). So here is small example of what i want

Ipconfig/all >> file.txt ...........this works fine but the next time that i run the file i would like a something like file2.txt created.
The only other thing that i tried but was wrong syntax was trying to append the time at the end of the file. for example i tried the following
ipconfig/all >> file%time%.txt.

Help would be greatly appreciated. Thanks
 
There is a basic command line utility called "now.exe" this returns the time and date...you should be able to get the outcome as a variable and include this in your script.


Remember: Backups save jobs!!!
;-)
 
could you please advise further how to do this as i can't even get now.exe command to work. I am using winxp.
 
Got solution i was looking for - If anyone interested see below.

for /F "tokens=1-4 delims=:., " %%a in ('time/T') do set TIME=%%a%%b%%c
for /F "tokens=1-4 delims=/- " %%A in ('date/T') do set DATE=%%A%%B%%C%%D


ipconfig /all >> %date%_%time%.txt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top