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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Want to use $DATE as logfile name.txt

Reply to Message Icon

Name: Brian
Date: February 25, 2002 at 15:07:03 Pacific
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!?!?!



Sponsored Link
Ads by Google

Response Number 1
Name: Brian
Date: February 25, 2002 at 15:49:17 Pacific
Reply:

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


0

Response Number 2
Name: Secret_Doom
Date: February 25, 2002 at 17:55:03 Pacific
Reply:

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


0

Response Number 3
Name: Brian
Date: February 26, 2002 at 07:43:12 Pacific
Reply:

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.


0

Response Number 4
Name: Secret_Doom
Date: February 26, 2002 at 15:56:26 Pacific
Reply:

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


0

Response Number 5
Name: Brian
Date: February 27, 2002 at 09:23:35 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Rejean Turcot
Date: March 5, 2002 at 07:28:41 Pacific
Reply:

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


0

Response Number 7
Name: mogul skier
Date: June 26, 2002 at 15:44:26 Pacific
Reply:

Try this:

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

set FILENAME=%PREFIX%backup.log


0

Sponsored Link
Ads by Google
Reply to Message Icon

Out of Environment Space ... Send info to screen and l...



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Want to use $DATE as logfile name.txt

Batch file to save date as part of file name www.computing.net/answers/dos/batch-file-to-save-date-as-part-of-file-name/2640.html

using date as VARiable for naming files www.computing.net/answers/dos/using-date-as-variable-for-naming-files/4867.html

System date as folder name www.computing.net/answers/dos/system-date-as-folder-name/6968.html