Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I don't think this can be done using batch commands/variables. Please see my post on the previous thread "reading text from a file" about the use of Qbasic to do this kind of thing. It would take, literally, just a few lines of Basic to do exactly what you want.
I've left Qbasic behind about 10 years ago, but I can tell you for a fact that what you want to do can be done in just 3 short lines of code.

WHAT? What did you said? Of course it's possible! It seems that some people are underestimating batch language these days...
@echo off
if "%3"=="" if not "%2"=="" if exist %1.%2 goto start
echo ERROR: invalid parameters, parameter missing or excess of parameters.
echo SINTAX: %0 filename fileextention
echo.
goto eof
:start
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 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%
for %%d in (tmp.bat tmp2.bat) do if exist %temp%.\$$%%d del %temp%.\$$%%d
REN %1.%2 %DATE%.%2
:eof
Be aware of line wrapping (cut-paste this text and I think it will be alright)-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Oh, I forgot saying:
CUT-PASTE that text and save it with a .bat extention. It will become a batch file (executable)
The sintax is:
batchname filename fileextention
Let's say you save it with the name COPYDATE.BAT, and you want to rename the file DATA.TXT to 02032002.TXT:
copydate data txt
Got it?
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Mr Doom. Wonderful! :):):)#
You've proved my point brilliantly. But why on earth go to all that palaver?

![]() |
Reading text from a file
|
running old DOS on new ha...
|

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