Computing.Net > Forums > Disk Operating System > Want to use $DATE as logfile name.txt

Want to use $DATE as logfile name.txt

Reply to Message Icon

Original Message
Name: Brian
Date: February 25, 2002 at 15:07:03 Pacific
Subject: Want to use $DATE as logfile name.txt
Comment:

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!?!?!


Report Offensive Message For Removal


Response Number 1
Name: Brian
Date: February 25, 2002 at 15:49:17 Pacific
Subject: Want to use $DATE as logfile name.txt
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 2
Name: Secret_Doom
Date: February 25, 2002 at 17:55:03 Pacific
Subject: Want to use $DATE as logfile name.txt
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 3
Name: Brian
Date: February 26, 2002 at 07:43:12 Pacific
Subject: Want to use $DATE as logfile name.txt
Reply: (edit)

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.


Report Offensive Follow Up For Removal

Response Number 4
Name: Secret_Doom
Date: February 26, 2002 at 15:56:26 Pacific
Subject: Want to use $DATE as logfile name.txt
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 5
Name: Brian
Date: February 27, 2002 at 09:23:35 Pacific
Subject: Want to use $DATE as logfile name.txt
Reply: (edit)

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


Report Offensive Follow Up For Removal


Response Number 6
Name: Rejean Turcot
Date: March 5, 2002 at 07:28:41 Pacific
Subject: Want to use $DATE as logfile name.txt
Reply: (edit)

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.TMP

DATE /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%%l

Set parseagr2="eol=; tokens=1,2* delims=., "
for /f %parseagr2% %%a in (%CURRFILE%) DO SET fname=%%a

Echo 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


Report Offensive Follow Up For Removal

Response Number 7
Name: mogul skier
Date: June 26, 2002 at 15:44:26 Pacific
Subject: Want to use $DATE as logfile name.txt
Reply: (edit)

Try this:

for /F "tokens=2-4* delims=/ " %%a in ("%date%") DO set PREFIX=%%c%%a%%b

set FILENAME=%PREFIX%backup.log


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Want to use $DATE as logfile name.txt

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge