Batch Script to Create Multiple Folders within Multiple Folders

You can create a variable with the A,B,C set, create another variable with the 1,2,3,4 set, and then put each set in a nested FOR loop and iterate each variable value accordingly from each set to get A1, A2, A3, B1, B2, B3 and so forth ensuring every combination is iterated.

You just use the MD command to create the directory combinations appended to the root directory where the main subfolders from group A set separated by commas will reside.

Script Example

Be sure to set the RootDir= value as the full path to the parent folder that will contain the group A list folders that are set as the SubA= variable.

@ECHO ON
SET RootDir=C:\Main
SET SubA=A,B,C,D,E
SET SubB=1,2,3,4,5
FOR %%A IN (%SubA%) DO FOR %%B IN (%SubB%) DO IF NOT EXIST "%RootDir%\%%~A\%%~B" MD "%RootDir%\%%~A\%%~B"
EXIT

Further Resources

  • FOR
  • IF
  • MD