I'm trying try create a folder structure of multiple folders within another folder.
The below script creates the same subfolders but not what I need.
@ECHO ON
SET RootDir=C:\Main
SET SubA=A,B
SET SubB=Rates,Docs,Fee,Category,Grades,6000,7,8,Falcon
FOR %%A IN (%SubA%) DO FOR %%B IN (%SubB%) DO IF NOT EXIST "%RootDir%\%%~A\%%~B" MD "%RootDir%\%%~A\%%~B"
EXIT
I need suppport to modify the script to create as per required folder structure.
- Main folder
- A
- Rates
- Docs
- Fee
- Category
- B
- Grades
- 6000
- 7
- 8
- Falcon
The assumption here is that you want to create the subfolders dynamically, even if you have more sub folders in
C:\MainMy other assumption is that the subfolders being numerical here is probably just a use case you gave to simplify the question.
I am posting this answer based on the examples you requested, if your real-world folders will be manually added as an environment variable, then this will not work with the numerical counter.
That is possible by iterating over the subfolders, then running a loop for each sub directory and creating the folders.
This will work even if you have more sub folders, i.e
C,D,Ebecause of thefor /lloop that increments only 4 counts per folder and will keep doing so until it has looped the entiresubsenvironment variable.