Here is the situation. You need to create several subfolders inside a folder and name them appropriately.![]()
One way is to create each folder one by one and then rename them again one at a time. This method would be fine if you had to create only a few folders. But what if you need to create several such folders. Doing it using the above method would be quite tedious and time consuming.
Here’s a little command prompt trick that can help you immensely.
- Open Notepad and type in a list of the names of the folders you need to create, with each name in a separate line.
- Save this file in the folder in which you want to create the sub-folders. This will save you the trouble of having to type out the entire path. Let’s call this file folders.txt.
- Open a command prompt in that folder and type:
FOR /F %n IN (folders.txt) DO MKDIR %n
and hit Enter. Within seconds the folder would all be created.
You can use any single letter instead of n, and the command will take each line of the file and DO a MKDIR with the name it finds.
A variant is to use:
FOR /F “tokens=*” %n IN (folders.txt) DO MKDIR %n
This version will process items on the same line, separated by spaces. To create folders with a space in the name, use the second method and enclose the name in double quotes. So, for example, a text file containing the line
“January February” March April May
will produce four folders when fed to the FOR command, the first being named “January February” and the others named March, April and May.
You May Also Be Interested In...
- Hide any file inside any other file
- Hiding an MP3 audio file inside a Gif/Jpg image
- How to print a list of contents of a Folder/Directory
- How to pin a folder to the task bar in Windows 7
- Add your own destinations to the ‘Send To’ context menu
- Create a password protected folder without any special software
- Mirror one folder to another and keep the files synchronised
- Pin frequently used folders to Vista’s Start menu
Subscribe Now
If you enjoyed this post, you will definitely enjoy our others. Subscribe to the feed to get future posts delivered right to your mailbox or feedreader.



{ 1 comment… read it below or add one }
Can you please continue – many helps thaks -
can you see if you can handle this simple task for me?
I have many folders with many required files with same extension in them.
Like so
C:\
C:Photoshop\
C:\Photoshop\templates
C:\Photoshop\templates\template1\file.*
C:\Photoshop\templates\template2\file.*
C:\Photoshop\templates\template2\file.*
Question how to execute all files from CMD window.
Thanks !