Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Win98 DOS name a file with the date.

12 views
Skip to first unread message

Homer Wilson Smith

unread,
Oct 6, 2022, 2:44:52 AM10/6/22
to
Running Win98 4.10.2222 DOS 5.x or 6.x batch scripts

Need to write a file or directory with the date.

echo %date% does not work as it does in future windows.

Is there a batch script command that will do this for me?

Thanks Homer W Smith (Lightlink CEO.)

--
------------------------------------------------------------------------
Homer Wilson Smith Clean Air, Clear Water, Art Matrix - Lightlink
(607) 277-0959 A Green Earth, and Peace, Internet, Ithaca NY
ho...@lightlink.com Is that too much to ask? http://www.lightlink.com

Robert Roland

unread,
Oct 6, 2022, 8:27:50 AM10/6/22
to
On Thu, 6 Oct 2022 02:44:50 -0400 (EDT), Homer Wilson Smith
<ho...@adore.lightlink.com> wrote:

> Running Win98 4.10.2222 DOS 5.x or 6.x batch scripts
>
> Need to write a file or directory with the date.
>
> echo %date% does not work as it does in future windows.
>
> Is there a batch script command that will do this for me?

If I remember correctly, Win98 did come with VBscript. It only works
in Windows mode, though.

Could that be an option?
--
RoRo

Auric__

unread,
Oct 6, 2022, 2:11:47 PM10/6/22
to
Homer Wilson Smith wrote:

> Running Win98 4.10.2222 DOS 5.x or 6.x batch scripts
>
> Need to write a file or directory with the date.
>
> echo %date% does not work as it does in future windows.
>
> Is there a batch script command that will do this for me?

If it needs to be DOS-compatible, QBasic is an option. (Robert's suggestion
of VBscript won't work under DOS.) Save this to a file called something like
"MDDATE.BAS":

'---begin---
'create directory using today's date as the name
ON ERROR GOTO ender
x$ = DATE$
'y$ is the created directory name in YYYYMMDD format
' year month day
y$ = RIGHT$(x$, 4) + LEFT$(x$, 2) + MID$(x$, 4, 2)
MKDIR y$
ender:
SYSTEM
'---end---

...and save this to something like "MFDATE.BAS":

'---begin---
'create file using today's date as the name
ON ERROR GOTO ender
RANDOMIZE TIMER
x$ = DATE$
'y$ is the created file name in YYYYMMDD format
'change ".txt" to whatever you want
' year month day
y$ = RIGHT$(x$, 4) + LEFT$(x$, 2) + MID$(x$, 4, 2) + ".txt"
z$ = LTRIM$(STR$(INT(RND * 100000000)))
'this nonsense needed because qbasic lacks functionality
SHELL "dir /b " + y$ + ">" + z$ + ".tmp"
OPEN z$ + ".tmp" FOR INPUT AS 1
IF LOF(1) < 1 THEN
'file does not exist; create
OPEN y$ FOR BINARY AS 2
END IF

ender:
ON ERROR GOTO ender2
CLOSE
KILL z$ + ".tmp"
ender2:
SYSTEM
'---end---

Then call the appropriate script at the point in your batch that you need to
create your file:

QBASIC /RUN MFDATE.BAS

...or directory:

QBASIC /RUN MDDATE.BAS

--
When life shuts a door, open it back up.
That's how doors work.
Then shut it again.

JJ

unread,
Oct 6, 2022, 6:20:01 PM10/6/22
to
On Thu, 6 Oct 2022 02:44:50 -0400 (EDT), Homer Wilson Smith wrote:
> Running Win98 4.10.2222 DOS 5.x or 6.x batch scripts
>
> Need to write a file or directory with the date.
>
> echo %date% does not work as it does in future windows.
>
> Is there a batch script command that will do this for me?
>
> Thanks Homer W Smith (Lightlink CEO.)

The %DATE% variable is an internal variable which is provided by CMD.EXE.
CMD.EXE does not exist in Windows 9x/ME. It only exist in NT based Windows,
and it can't run under Windows 9x/ME.

For Windows 9x/ME, without downloading additional software, the alternative
method is to use Windows Script Host (WSH) with either VBScript or JScript.

With additional software download, my recommendation is to use the open
source 4DOS (formerly a JPSoft's proprietary software). 4DOS is a
replacement for COMMAND.COM and has CMD capabilities (and more). It's 99%
compatible with CMD.EXE and COMMAND.COM.

https://www.4dos.info/

Klaus Meinhard

unread,
Oct 7, 2022, 3:25:05 AM10/7/22
to
Am 07.10.2022 um 00:19 schrieb JJ:

> With additional software download, my recommendation is to use the open
> source 4DOS (formerly a JPSoft's proprietary software). 4DOS is a
> replacement for COMMAND.COM and has CMD capabilities (and more). It's 99%
> compatible with CMD.EXE and COMMAND.COM.
>
> https://www.4dos.info/

.. which has the TOUCH command to change file and directory timestamps.


--
Mit freundlichen Grüßen,

* Klaus Meinhard *


Klaus Meinhard

unread,
Oct 7, 2022, 3:36:38 AM10/7/22
to
Am 07.10.2022 um 09:25 schrieb Klaus Meinhard:

.. and it might be funny to compare my (mostly) 1-line 4DOS solutions
to Timo's Batfaq list today:

<https://www.4dos.info/4batfaq.htm>

Even today, JP Software's Take Command, the successor to 4NT and 4DOS,
is way ahead of Microsofts CMD and Powershell. There's a free version
called TCC/LE on theit website.

Herbert Kleebauer

unread,
Oct 9, 2022, 7:20:54 AM10/9/22
to

On 06.10.2022 08:44, Homer Wilson Smith wrote:
> Running Win98 4.10.2222 DOS 5.x or 6.x batch scripts
>
> Need to write a file or directory with the date.
>
> echo %date% does not work as it does in future windows.
>
> Is there a batch script command that will do this for me?
>
> Thanks Homer W Smith (Lightlink CEO.)
>

:::::::::::::::::::::::::::::::::::::::::::::
echo set date=%%2 >call._1_
dir call._1_ |find "_1_" >_2_.bat
ren call._1_ _1_.bat
call _2_.bat
del _1_.bat
del _2_.bat
echo %date%
:::::::::::::::::::::::::::::::::::::::::::::

In NT+ this works only if you use the /-n in the dir command:
dir /-n call._1_ |find "_1_" >_2_.bat


Or a more flexible version (works only in DOS or 32 bit Windows):

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>d_t.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>d_t.com
echo LisqMz`wGH@wKuur`G@w?ogBgGG}G?j_egoNOG?w?`gBLksqgG`w?WgBgG>>d_t.com
echo G}G?R_MgoNMy?wSx@W?s?W?@zAB`LrFuBLyt~vuco{@LuKooD?BFHqrIcP>>d_t.com
echo _sdDxb1T??=?rILO_sdDqx1T??=?rILO_sdDnl1T??=?rILO_sdD`c1T??>>d_t.com
echo =?rILO_sdDgg1T??=?rILO_sdDll1T??=?rILO_sdDrr1T??=??IL?0xxx>>d_t.com

d_t.com>d_t.bat
call d_t.bat
del d_t.com
del d_t.bat

echo century: %_cy%
echo year: %_yr%
echo month: %_mo%
echo day: %_da%
echo hour: %_hh%
echo minute: %_mm%
echo second: %_ss%






0 new messages