I want to create a folder structure like this:


The folders (folder1, folder2 etc.) already exist, but I want to add the subfolder to each one. Yes, I can just go into each folder, and add it in individually, but I was wondering if there was an easier way to do this?

  • Is there a pattern for your sub-folders - if yes, then it becomes much easier to do it with batch files – Prasanna Apr 10 '15 at 3:54
  • @Prasanna the subfolders are just going to be created in the lowest step of the folder structure, all with the same name. – Ben Apr 10 '15 at 4:16

If running Windows, you can use batch files. The command to make a directory is mkdir and you can use for to iterate through the files in the directory.

This should do the trick, replacing 'name' with whatever you want the subfolders to be called and 'path\to\dir' with the path to the directory containing the subfolders. Either save this as a file ending in .bat and run it, or run the command prompt and type and run both these lines.

cd path\to\dir
for /d %%g in (*) do mkdir "%%g\name"
  • Does this create many subfolders in one parent folder, or one subfolder in each of many parent folders? – Ben Apr 11 '15 at 8:37
  • @Ben Creates one subfolder with the same name in each of many parent folders, assuming all the parent folders are located within path\to\dir. – kstew Apr 13 '15 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.