need help with wrapping a loop around the following code

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
robertwig
Posts: 2
Joined: 24 Jan 2014 06:45

need help with wrapping a loop around the following code

#1 Post by robertwig » 24 Jan 2014 06:55

I have the following dos batch code that works fine for me as it is, but I need to wrap it in a loop that searches for the folder on all system drives and if it doesn't find the folder it exits:

cd \
echo
for /f "tokens=1,2 delims=:" %%A in ('dir /d MyOFFSetupFiles ^| findstr "\<Directory of\>"') do (
for /f "tokens=1-3 delims= " %%G in ("%%A") do (set "findPath=%%I:%%B" & set drvltr=%%I) )
echo drive is %drvltr%
echo folder path is %findpath%
pause

Any assistance would be greatly appreciated.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: need help with wrapping a loop around the following code

#2 Post by foxidrive » 24 Jan 2014 07:46

Didn't you like the code that you got on another forum? :D

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: need help with wrapping a loop around the following code

#3 Post by Squashman » 24 Jan 2014 08:11

foxidrive wrote:Didn't you like the code that you got on another forum? :D

Ditto
http://www.computerhope.com/forum/index ... 389.0.html

robertwig
Posts: 2
Joined: 24 Jan 2014 06:45

Re: need help with wrapping a loop around the following code

#4 Post by robertwig » 24 Jan 2014 17:09

Folks;

I now have a working batch file so you can consider this post closed.

Thanks

Post Reply