Click here for important information about

Solved For loop to find folder batch file

August 15, 2012 at 05:39:59
Specs: windows xp
Hi all...

I have a batch file to map a server to a "x" drive
Then to search folders called user1 user2... Upto user7,
This might get more directories over a few months etcetc

For a folder named after the user which I prompt to search for
Say bloggsp5 is the name...

It searches user1 by the pushd command and popd back if not found
And pushd to the next folder...

Then I have returned a echo saying bloggsp5 was found in section-IT\user4\...

Now my batch file is very very long and hard to look at
(have many "sections-agencies" ie... IT Or HR...)

I hope this is understandable?

Can this be done in a for loop? That's my question,
instead of having a bat file ten miles long?

Oh and I use CLIP.EXE to paste to clipboard to paste in notepad the findings...
I don't know if that can work also ?


See More: For loop to find folder batch file

August 15, 2012 at 10:57:00
Break each section out into their own files and then CALL them when you need them from a "driver" batch script.


Report •

August 15, 2012 at 19:54:15
✔ Best Answer
I am (as usual) confused. Why can't you search from the root of X:\
is this a "permissions" issue? I am probably way out in left field, or maybe even absent from the ballpark, but here's a rough-edge for what I would do.

@echo off & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('dir /s /ad X:\*\user?\%1') do echo %%a

this is assuming that bloggsp5 is a directory.
also, post your code...

Report •
Related Solutions

Ask Question