Loop Syntax error in MS-DOS 6.22

762 Views Asked by At

I'm trying a script to get the last modified date on a virtual PC running MS DOS 6.22. But whenever I find a solution which includes a loop, it shows syntax error in the console. Here's one of the lines that shows this :

for /d %%a in ("C:\log") do echo Modified date: %%~ta

Is dos 6.22 incompatible with the loops ? I have a lot of restrictions with this version (can't use robocopy, date, etc...)

1

There are 1 best solutions below

1
jeb On

The loop syntax is supported, but a bit limited (see also for /?).

FOR %A in (filelist) do myCmd %%A

So there are no switches at all.

As I remember in the most cases it wasn't possible to catch data with DOS.
It was really hard stuff even to split a simple string.

But if you absolutly need it (or have fun with it) you can split a string with a FOR loop into the first character and the rest by

for %%A in (/%var%) do echo %%A

But to save the first character is a bit tricky...

Or you could use edlin or debug to parse strings.

Advanced stuff like request the last modified date of a file was behind the possibilities of ms-dos.

But why you don't try it from your host computer to access the inner file system of the VM?
Then you could also use all modern technologies like cmd.exe batch