Wednesday, March 11, 2009

Creating multiple subfolders using MKDIR from a command prompt

Some time you need to create several subfolders inside a folder and name them appropriately.

One way is to create each folder seperately with appropriate name. This method would be fine if you had to create only a few folders. But if you need to create several such folders. Doing it using the above method would be quite tedious and time consuming.

Here is a little command prompt trick which helps to do this easily.

Step 1: Open notepad and type list of folder names which you want to create with each name separated by space as shown below.



Step 2: Save the above file as "FolderNames.txt" in the folder in which you want to create the sub-folders as shown below. (Note: Here I save it under "C:\MultiFolder" directory)



Step 3: Open the command prompt in that folder and type the following command as shown below.

<FOR /F "tokens=*" %n IN (FolderNames.txt) DO MKDIR %n>



Step 4: Now you can see all the subfolders created successfully as shown below.



With this example, FolderNames.txt file containing the line

<subFolder1 subFolder2 subFolder3 subFolder4 "sub Folder 5">

Which will results to create five subfolder with the name subFolder1, SubFolder2,
subFolder3, SubFolder4 and "sub Folder 5".

No comments:

Post a Comment