How to write a batch file to create a folder structure using a master list of directory/sub-directory names or a "Table of Contents"

I have a master filing list of directories and sub directories (about 600+  that we use to create folders and sub folders in windows explorer - example -
1.1      General
1.1.1      File Index
1.1.2      Project Directory
1.1.3      Administration Correspondence

and we have sub folders under general using similar numbering structure -
What I could not figure out is how to get spaces and dots in the the batch file -
I did try the following dos bat file but it did not work -
I know there must be a simpler way of "calling a text file" containing this list to create a folder sturcture -

I bow to the superior knowledge out there -

Thanks
Bramha
Master-list.txt
bramhaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brett CrawleyZone LeaderCommented:
Hi Bramha

The following batch file takes a file containing a list of directory names one per line as a parameter and will create the structure, this doesn't drill down though it simply creates a flat structure. Also the names must contain only characters valid in a directory name, for example a tab character may not be used but a space character may be used.

@ECHO OFF

IF "%~1" == "" GOTO :HelpMessage
SET INFile="%~f1"

FOR /F "delims=;" %%A IN ('TYPE %INFile%') DO CALL :ParseFile "%%A"
GOTO :ExitBatch

:ParseFile
md "%~1"
GOTO :ExitBatch

:HelpMessage
ECHO Usage FolderList.bat ^<filename^>
GOTO :ExitBatch

:ExitBatch

Regards

Brett
0
bramhaAuthor Commented:
Hello Brett -
Thank you for your patience and support -
Let me give this a try and will respond immediately

Best
Bramha
0
bramhaAuthor Commented:
Hello Brett -
Are "numbers" and "dots or Periods" valid characters - ?

Bramha
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Brett CrawleyZone LeaderCommented:
Hi Bramha

Numbers and dots should work fine, the only characters that are not allowed are those you cannot use within a filename. A filename cannot contain any of the following characters:

\ : * / " ? < > |

I tried the code here with the attached file and it worked fine, although all directories were created under the same directory.

However if you were to include the structure in a text file in this way outlined below it would create the complete tree structure but you would have to make sure that the parent directories were created first:

1.1 General
1.1 General\1.1.1 File Index
1.1 General\1.1.2 Project Directory
1.1 General\1.1.3 Administration Correspondence
1.2 Contracts and Proposals
1.2 Contracts and Proposals\1.2.1 General Agreement
1.2 Contracts and Proposals\1.2.2 Consultant RFPs

Hope that helps.

Regards

Brett
folder-list.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bramhaAuthor Commented:
Hi Bramha - I apologize for the late response - I am currently travelling - and have a 12 hr difference with the US -

Got It - let me give it a try - and I will post a response soon

Thank you for you help -

Best
Bramha -
0
bramhaAuthor Commented:
Hello Brett -

Fianlly I have edited the master list to reflect the changes that you suggested - (all 600 + directories) took a while -
Question to you -
What do I call the file - (currently named master-filing-list)
Where should it be located - path
Should I edit the batch file that you sent to refelect that name -
 -
Because i tried running the script and nothing happend -
Bramha
0
bramhaAuthor Commented:
Hello Brett -

Finally figured it out - thanks a ton - maybe for your research - I feel that there could be an easier way than creating all those sub-tree structure of the directory sturcture -

All said and done - you were wonderful - and thank you once again -

Best
Bramha
0
Brett CrawleyZone LeaderCommented:
Hi Bramha

It doesn't matter where your master-filing- list or where you put the batch script as long as you include the full paths or relative paths to them when you call the script and you need to be in the root directory where you want the directories to be created. For example assuming you have called the batch file FolderList.bat as I had and that you had placed it in c:\ and assuming that your master-filing-list.txt was in  
"c:\Some Directory\master-filing-list.txt", you simply call it as follows:

c:\FolderList.bat "c:\Some Directory\master-filing-list.txt"

from the directory where you want the structure to be created.

Regards

Brett
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.