Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need to write a DOS Batch file that renames a file to it`s original name plus todays date.
e.g. TEST.TXT becomes TEST220102.TXT
I need the batch file to dynamically look up todays date and append the correct date each time the file is run. Thanks.

That sounds pretty interesting, man... I wouldn't mind checking that out myself on my DOS box at home. I'm at work until 8pm PST right now, and we only run NT here, but when I get home, I'll check it out and see what I can do.
You should submit here if you find it, because it sounds pretty cool too.
DOS rules, by the way.

The following script is deactivated.
Run it and see if it prints out on the screen the correct operation. If it does so, activate the script by taking out the "EcHo" from the line indicated.=== Script begin (omit this line) ===
@echo off
echo @PROMPT SET DATE=$D$_>%temp%.\$$tmp.bat
%comspec% /c%temp%.\$$tmp.bat>%temp%.\$$tmp2.bat
echo e111';'> %temp%.\$$tmp.bat
echo e114';'>> %temp%.\$$tmp.bat
echo e117';'>> %temp%.\$$tmp.bat
echo w>> %temp%.\$$tmp.bat
echo q>> %temp%.\$$tmp.bat
debug.exe %temp%.\$$tmp2.bat<%temp%.\$$tmp.bat>nul
call %temp%.\$$tmp2.bat
echo SET DATE=%%2%%3%%4> %temp%.\$$tmp.bat
call %temp%.\$$tmp.bat;%date%::Take out the "EcHo" to activate script
EcHo REN TEST.TXT TEST%DATE%.TXTif exist %temp%.\$$tmp.bat del %temp%.\$$tmp.bat
if exist %temp%.\$$tmp2.bat del %temp%.\$$tmp2.bat
SET DATE==== Script end (omit this line) ===
! WATCH OUT FOR LINE WRAPPING !
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.brPS: Batch programmers: I know this script could be greatly reduced by using FOR, but I didn't use it to avoid more line wrapping

BTW: The following lines from script from my last post have wrapped:
echo @PROMPT ... $$tmp.bat
%comspec% ... $$tmp2.bat
debug.exe ... >nul
echo SET DATE= ... > %temp%.\$$tmp.bat
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Hey... now I refreshed the page and my first reply was cutted, besides the line that has "debug.exe" on its begin have being modifyed. I don't know what's happening to this f---ing forum, so I uploaded that script:
www.batch.hpg.com.br/dateren.txt
Just download it and rename its extention to .bat
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Look for a utility called FDATE.exe. This makes life much easier. It was written by Stephen Ferg in 1997 and works on all Windows platforms.
I downloaded it from:
http://sac-ftp.externet.hu/utiltask3.html
aap

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

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