views:

1432

answers:

1

Hi,

for testing purposes i need an recursive directory with some files, that comes to maximum path-length.

The Script used for the creation consists only of two for-loops, as followed:

for /L %%a in (1 1 255) do @(
    mkdir %%a
    && cd %%a
    && for /L %%b in (1 1 %random%) do @(
      echo %%b >> %%a.txt
     )
)

Now I would like to embed this script as part of another script, since more is to be done, but I can not add any other commands around it or it refuses working. I use this under windows vista, if this is useful to you.

Nor it works if i write "@ECHO OFF" in first line, neither with "echo done" on the last line.

output on commandline is:

X:\Scripte>recursive.cmd
OFFfor /L %a in (1 1 255) do @( mkdir %a
The system cannot find the path specified.

EDIT: Seems to be a problem with layer 8, the problem seems to be in the command shell used, if used the bare cmd.exe, it works, with visual studio 2008 command shell it does not work, like stated above.

anyway, thank you.

+1  A: 

I don't think you need the '@'s in front of the parens or the '&&' within the for loop body; the parens take care of handling multiple statements in the for loop.

The following works for me:

@echo OFF

for /L %%a in (1 1 255) do (
    @echo a = %%a
    mkdir %%a
    cd %%a
    for /L %%b in (1 1 %random%) do (
        echo %%b >> %%a.txt
    )
)

@echo done
Patrick Cuff
BeowulfOF
Patrick Cuff
Patrick Cuff