Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm have been trying to figure a way to write a batch file that will automatically rename a specific file by the date and time.
Someone Put One Idea Way On But This Does Not Seem To Work. The Problem Is That When You Get The Date Off DOS There Is Back Slashes In So You Can Not Rename A File Like This.Has Anyone Got Any Ideas.
Thank You

If you don't mind adding an executable to call from your batch file, you can use datename.exe, available inside datechk.zip, which is available at my website.

A setdatec.zip file can be found at the University of Vassa website http://garbo.uwasa.fi/pc/batchutil.html. This requires calling setdate.com and uses the included setdate.doc file. The program sets several environment variables which can then be used to customize unique file/directory names with date/time values. I ran the following simple test and it works well. Thank you for the question, I've had this same question for several weeks now. Just got it to work for the first time. Calling the program at least allows great flexibility in date/time values used.
cpdate.bat test file contents with setdate.com and setdate.doc in same directory
@ECHO OFF
setdate > dte.bat
call dte.bat
DEL dte.bat
copy a.txt .\backup\a%TODAY%%HR%%MIN%%SEC%.txt
echo *** File a.txt has been backed up to \backup\a%TODAY%%HR%%MIN%%SEC%.txt ***
echo *** File backup is complete. ***

I have invented a pure batch solution for parsing dates containing slashes. See here:
http://home7.inet.tele.dk/batfiles/main/batchfaq.htm#73

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |