1.

Solve : Batch file help???

Answer»

Hi!

here is my problem:

I try to create a BATCH file to isolate each caracter from a variable.. (from the curent date)

Here is an exemple for windows 2000/XP:

@ECHO off
Set char0=%date:~0,1%
Set char1=%date:~1,1%
Set char2=%date:~2,1%
Set char3=%date:~3,1%
Set char4=%date:~4,1%
ETc..

This batch file work great in windows XP and 2000 but i wanna do the same THING for windows 98,

Does anybody know how to do that?No not really. I'm not sure that %date% is even valid in Win98.

You can isolate the mm, dd, yyyy easy enough but there are no delimiters between the individual characters of mm, dd, yyyy.

Code: [Select]
for /f "tokens=2-4 delims=^/ " %%i in ('date /t') do (
set mm=%%i
set dd=%%j
set yy=%%k
)


Not really what you want, but DOS batch is functionally limited. Thanks for your answer,

I have another question, can you do that for the "time" command too?

can i isolate the hours, minuts, seconds, from the current time?I have finally try your script on a win98 computer and its not working... (but it work under windows XP)

Windows CANT reconize the "/T" after the "date"

So, Windows 98 return "syntax error" when he execute the first line of your script.

Any other ideas?


Always have ideas. Whether the're any good is another story. I don't remember Win98 being so primitive.

Code: [Select]
@echo off
for /f "tokens=6-8 delims=^/ " %%a in ('echo. ^| date') do (
set mm=%%a
set dd=%%b
set yy=%%c
)
for /f "tokens=5-8 delims=:. " %%a in ('echo. ^| time') do (
set hh=%%a
set mn=%%b
set ss=%%c
set ms=%%d
)


Note the hh variable (hours) is MILITARY time and the ms variable is 1/100's of a minute. Plan accordingly.

Hope this helps.



Discussion

No Comment Found