Dibbler,
Sorry for the confusion, I used "Batch" in my test script, so I apologize for the confusion, you can replace "Batch" with "Records Drawings n Documents" in both places.
But I will run down the code for you:
run that DIR command from the C:\ prompt...
DIR /s "Records Drawings n Documents"
Review the results, then add the find portion:
DIR /s "Recordings Drawings n Documents" | FIND "Directory"
The ^ character in that string is only necessary in the batch file, from a command prompt you can just type the pipe character.
That produces a list of ALL of the parent directories that contain a file or folder called "Records Drawings n Documents"
So if you compare the output of the two commands above, you'll see what the find is doing for us that the DIR was not.
We already knew WHAT we were looking for, "Records Drawings n Documents" the DIR command tells us WHERE to look for it at. And the FIND command breaks that down into a list and gets rid of most of the useless bits we didn't need to know about.
So now we have a list that looks like this:
Directory of C:\Users\Me\Folder
Directory of C:\Users\Me\Documents
Directory of C:\Users\Me\Data
Now the for loop will go through each one of those lines and set %%a to whatever we tell it to set a%% to. We use the tokens and delims for that.
We're going to set a space as our delimiter and multiple delimeters are counted as 1.
Now tokens tells the for loop what data to use to set a%% and b%% and c%% etc... but we're only using 1 variable so we only need 1 token. We want the path part, the C:\Users\etc... part of the line. So we use Tokens=3 we want the 3rd token. If we wanted 3 tokens, we'd use Tokens=1-3 to specify a range, but we specifically want token number 3.
The tokens are the peices of data seperated by the delimiter, so Directory is Token 1, of is token 2, and C:\users\Me\Data is token3.
We could have also done this:
For /F "tokens=1-3 delims= " %%a in (Our command that I'm too lazy to retype right now) DO echo %%c
%%a would be set at token1, %%b would be set at token2 and %%c would be set as token3 which is the token we wanted.
I think you actually have a handle on the rest of it but here it is:
.... DO Dir "%%a\Records Drawings n Documents" /s /b >> "C:\test.txt"
%%a is actually equal to C:\Users\Me\Folder
You're adding the \Records Drawings n Documents part and then redirecting the output of that second DIR command to C:\Test.txt which is also what I was using to test, you can change that to whatever you want.
The next pass through the FOR loop, %%a will be = C:\Users\Me\Documents and so on and so forth.
The results are a list of fully qualified path names for every file in every "records Drawings n Documents" folder on drive C:
My command might be easier to read, but I like Dave's better, findstr is much more capable than FIND, but I'm a creature of habbit.
Sorry for being thick, I do a bit of sudo coding (generally VB.net) with external coders but I desperately need to get better at quick dirty batch files. However I can’t find a good resource for learning, you don’t know of one do you? Not DOS because I'll just get confused as to what works, just the Command window & batch files within Win 7. I'm more than happy to pay for a book if one exists.
I know of several good resources...
1. This site.
2.
http://technet.microsoft.com/en-us/libr ... 2390(WS.10).aspx
3.
http://www.robvanderwoude.com/news.phpThe 3rd site has scripts dating all the way back to DOS and OS/2, but there is also a lot of newer stuff and they typically specify what versions it works in. If it says NT/XP or WIN2k then it still works. A lot of the older stuff still works too though.
EDIT: Just noticed that Dave's first script does the exact same thing as mine, the |FIND "string" is replaced with adding the /b /ad switches on the directory command and eliminates the need to use tokens.