Computer Hope

Microsoft => Microsoft DOS => Topic started by: tlm2408 on January 24, 2017, 04:21:07 AM

Title: batch file to run vbscript in all subfolders
Post by: tlm2408 on January 24, 2017, 04:21:07 AM
Hello,

I have been trying for days to create a batch file that will run a vbscript (dirlist.vbs) in every subdirectory and sub subdirectory of the parent directory. Is this even possible. I have found some examples that come close to what I am looking for through searching, but I can't make sense of them.

Any help would be greatly appreciated.


Never mind I got it worked out. For anyone looking for this:

Code: [Select]

@echo off
call :treeProcess
goto :eof

:treeProcess
rem Do whatever you want here over the files of this subdir, for example:
for %%f in (*.vbs) do cscript %%f
for /D %%d in (*) do (
    cd %%d
    call :treeProcess
    cd ..
)
exit /b

Title: Re: batch file to run vbscript in all subfolders
Post by: Squashman on January 24, 2017, 06:33:38 AM
Well your code is still not setup correctly.

If all your vbscript does is iterate a directory listing you can easily do that a couple of ways with native batch script.