midiboy Posted December 13, 2008 Share Posted December 13, 2008 Hi guys,if anyone has an idea, please let me know ! :-)I would like to start a cmd that recursively searches through subfolders and starts each cmd called install.cmd it finds in those subfolders.I do have this code to start the cmd inside the current folder but how do I make it go through each subfolder inside this folder and start all files called "install.cmd" instead ?set p=%~dp0for %%i in ("%p%install.cmd") do start "" /wait %%iAny ideas ? Thanks a lot !Alex Link to comment Share on other sites More sharing options...
Yzöwl Posted December 14, 2008 Share Posted December 14, 2008 You could try something along these lines:@for /f "delims=" %%i in ('dir/b/s/a-d install.cmd') do @call "%%~i"Incidentally in the example you gave, because you can only have one file named install.cmd in a single directory, this would have done:@call install.cmd Link to comment Share on other sites More sharing options...
midiboy Posted December 14, 2008 Author Share Posted December 14, 2008 Hi Yzöwl,I was sure you would answer ! Thanks for the code, will try it soon,have a nice evening/day,Alex Link to comment Share on other sites More sharing options...
midiboy Posted December 16, 2008 Author Share Posted December 16, 2008 Hi Yzöwl,unfortunately it does not work just yet the way it is now. The script now starts itself over and over and never comes around to starting any of the scripts in the subfolders. Thats probably because the script that contains your code is also called install.cmd and it calls itself over and over ... any easy way around that except renaming that script in the top dir ?Also, I had troubles with your call command. It did not really work. As soon as I changed it to this:@for /f "delims=" %%i in ('dir/b/s/a-d install.cmd') do start "" /wait "%%~i" ... it worked.Anyway, I have this working now. If you want to spend some time on the first issue above, I would be very thankful. If not, don´t bother Bye,Alex Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 16, 2008 Share Posted December 16, 2008 (edited) If you want to try a VBS script to go threw the sub folders and only run the install.cmd in the sub foldersSave As Install.vbsOption Explicit Dim Act :Set Act = CreateObject("WScript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Col, Obj, Str'-> "." Current Directory The Script Is In Set Str = Fso.GetFolder(".") For Each Obj In Str.SubFolders For Each Col In Obj.Files '-> Filter Out The Name If InStr(UCase(Col.Name),UCase("install.cmd")) Then '-> Make Sure It install.cmd and not SomeAppInstall.cmd Or AppInstall.cmd If Len(Col.Name) = 11 Then Act.Run(Chr(34) & Col.Path & Chr(34)),1,True End If End If Next Next Edited December 16, 2008 by gunsmokingman Link to comment Share on other sites More sharing options...
floko84 Posted December 16, 2008 Share Posted December 16, 2008 @for /f "delims=" %%i in ('dir /b /s /ad') do @if exist "%%i\install.cmd" call "%%i\install.cmd" Link to comment Share on other sites More sharing options...
midiboy Posted December 17, 2008 Author Share Posted December 17, 2008 Hi !Thanks guys for your help ! :-)Happy X-mas !Alex Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now