1.

Solve : How Do I Execute Same Command in Current Directory's Children Directories??

Answer»

For any given directory, all I WANT to do is go into each of its immediate child directories and execute the same command.

I originally was thinking about taking the command of "dir /AD /B /X" and store it into a txt file, but after that, I'm not really sure what I can do. I need to go into each child directory since the OUTPUT of the command I want to do creates files that populate whatever the current directory is.

Is there a quick fix to this?

This is my pseudo-code:

Code: [Select]FOR %%d in (dir /AD /B /X) DO (

cd %%d
REM excecute command here
cd ..My other idea was this:

dir /AD /B /X > dir.txt

FOR %%d in (dir.txt) DO (
cd %%d
REM excecute command here
cd ..
)
I just FOUND out the /X is useless when trying to store the old MS-DOS 8.3 filename LIMITATION since when I redirect to a txt file, it opts to use the longer filename convention.

I'll have to figure out how to wrap directories with quotes.Okay even though I got no help, I perused through the forum and looked in some other people's scenarios which vaguely had some similar needs as mine. I THINK this is my solution.... I have to wait since I can't run the bat file until my current process ends on my server. But here is what I think will do the trick:

Code: [Select]FOR /F "delims==" %%d in ('dir /AD /B /X') DO (

cd "%%d"

cd

REM insert executable command here

cd ..

)



Discussion

No Comment Found