@echo off
setlocal
SET "sourcedrive=Z"
SET "destdrive=C"
SET /a year=2013
SET "projections=2 - November Projections"
SET "Estimates=November Estimates"
DIR /b /ad "%sourcedrive%:\%year%\%projections%" >fundfamily.txt
start /wait "Fund Family" C:\Windows\System32\notepad.exe "fundfamily.txt"
FOR /f "delims=" %%a IN (fundfamily.txt) DO (
ECHO MD "%destdrive%:\%year%\%projections%\%%~a"
DIR /b /ad "%sourcedrive%:\%year%\%projections%\%%~a" >entitylist.txt
start /wait "%%~a entities" C:\Windows\System32\notepad.exe "entitylist.txt"
FOR /f "delims=" %%b IN (entitylist.txt) DO ECHO MD "%destdrive%:\%year%\%projections%\%%~a\%%~b\%year%\%estimates%"
)
It's incredibly difficult to solve a problem stated as ""my code doesn't do what I want it to do" without an indication of sample data or desired outcome.
For instance, you could provide a partial listing such as
fundfamily.txt
Jones
Brown
de la Vedova
Smith
entitylist.txt
Stock - Confusion Industries
Sweatshop Industrial Inc.
Royalties - Useless Invention
123, Slum St., Gloomsville
and a note like the entity list changes for each fundfamily
- or renaims the same, or whatever. You can Edit
this data into your question - 'tis what the Edit
link under the tags is used for.
As for the above code - I've assumed that the structure is as I have indicated. I would suggest that it would be quite an onerous task if you have hundreds of fundfamily
entries, but we have no further data to go on...so it's "air" code - untried for absence of available data.
Note that the first quoted string in the start/wait
line becomes the window title. If you don't want a window title, use an empty string ""
I've left C:\Windows\System32\notepad.exe
in place, but it's quite likely that simply notepad
would suffice, or even that it could be omitted entirely. The /wait
is the magic - this waits until the executable is finished before the batch proceeds to the next step.
Also note that the MD
commands (MD
and mkdir
are synonyms) are merely echo
ed - so that you may test without actually changing anything. You'd need to remove the echo
keyword before the md
to actually create the directories.