Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to use the date as part of the logfile naming convention in MS-DOS, here is an example ... 022502backuplog.txt
I am running version 5.00, please help!?!?!

Let me clarify, I want to assign a variable such as %DATE%backuplog.txt to automatically generate the date that gets added to the file name. This is for automatically created backup logs at 3 a.m.
BT

Get date without separators:
http://www.secretdoom.hpg.com.br/us/faq.html#getdate2.bat
I'm not sure if it works on Dos5.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Those batches wouldn't work for me. Still can't get the date to appear without all of the slashes, and the Day of the week as well. Any more ideas anyone, I just need to get the value of %DATE% to look like this, ... 02262002 so I can append it as part of my log file name.

That's exately what that script is supposed to do... It didn't work? What was the result?
Just in case, I'm posting below the script (just want to be sure you did tryed the right one)
=== SCRIPT BEGIN ===
:: getdate2.bat
:: Get date into %date% without separators
@echo off
echo @PROMPT SET DATE=$D$_> %temp%.\$$tmp.bat
%comspec% /c %temp%.\$$tmp.bat > %temp%.\$$tmp2.bat
rem > %temp%.\$$tmp.bat
for %%s in (e111''3B e114''3B w q) do echo %%s>> %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%
for %%d in (tmp.bat tmp2.bat) do if exist %temp%.\$$%%d del %temp%.\$$%%d
echo DATE="%DATE%"=== SCRIPT END ===
BE AWARE OF LINE WRAPPING !
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

I copied the script and created a batch out of it called date.bat. Concluding execution, here is the result ...
C:\BatchScripts>date.bat
DATE="02/27/2002"Still has the slashes?
Brian

Here the batch I use to place the date in the name of a file:
@Echo OFF
TITLE DateName
REM DateName.CMD
REM takes a filename as %1 and renames as %1_YYMMDDHHMM
REM
-------
IF %1.==. GoTo USAGE
Set CURRFILE=%TEMP%\CURRFILE.TMP
Set CURRDATE=%TEMP%\CURRDATE.TMPDATE /T > %CURRDATE%
ECHO %1 > %CURRFILE%Set PARSEARG="eol=; tokens=1,2,3,4* delims=/, "
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET DDMMYYYY=%%j%%k%%lSet parseagr2="eol=; tokens=1,2* delims=., "
for /f %parseagr2% %%a in (%CURRFILE%) DO SET fname=%%aEcho RENAME %1 %fname%_%DDMMYYYY%.log
rename %1 %fname%_%DDMMYYYY%.log
GoTo END:USAGE
Echo Usage: DateName filename
Echo Renames filename to filename_DDMMYYYY
GoTo END:END
REM
TITLE Command Prompt

Try this:
for /F "tokens=2-4* delims=/ " %%a in ("%date%") DO set PREFIX=%%c%%a%%b
set FILENAME=%PREFIX%backup.log

![]() |
Out of Environment Space ...
|
Send info to screen and l...
|

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