nosmokingbandit Posted October 24, 2008 Report Share Posted October 24, 2008 I have a command line program that creates text/html files in a specific directory. The problem is that it will overwrite the old copies if i run it again without renaming the old copies. Is there a way to make DOS sve a file as the current date and time. The app's syntax is the following:app.exe /shtml [filename].htmlapp.exe is the program of course, the /shtml tells it to save the file as html and the filename part is self explanatory. What can i do to make this save each file with a timestamped title? Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted October 24, 2008 Report Share Posted October 24, 2008 Welcome to the Windows Forum.It depends if you have control over your application, i.e. if you are able to modify it.If yes, just change it to append date & time to the filename.If not, append the DATE and TIME environment variables to the filename in your line command, e.g.app.exe /shtml [filename.%DATE%.%TIME%].htmlP.S. see this article if you want to remove dashes, colons, etc. from the standard DATE/TIME environment variableshttp://en.wikipedia.org/wiki/Environment_v...crosoft_Windows Quote Link to comment Share on other sites More sharing options...
nosmokingbandit Posted October 24, 2008 Author Report Share Posted October 24, 2008 Awesome. I didnt even think of checking wiki (my geek sense must be wearing thin, lol). I ended up doing this:@echo off echo %DATE% %TIME%set MTH=%DATE:~4,2%set DAY=%DATE:~7,2%set YR=%DATE:~12,4%set HR=%TIME:~0,2%set HR0=%TIME:~0,1%if "%HR0%"==" " set HR=0%TIME:~1,1%set MIN=%TIME:~3,2%set SEC=%TIME:~6,2%set MYDATE=%MTH%-%DAY%-%YR%-%HR%hr%MIN%m%SEC%sstart app.exe /shtml ff\%MYDATE%.htmlwhich give me the output:10-24-08-00hr39m27s.htmlCould not be better, imo. Thanks a ton for the help, i really appreciate it! Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted October 24, 2008 Report Share Posted October 24, 2008 You're welcome. You know, I didn't go and check Wikipedia, I just googled B) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.