Scripting question. Dang, it should be easier than this. I have a file with a list of names. I'd like to turn those names into folders. Whenever I try the FOR loop, all I get is the name of the file I want to read from being created as a folder, not the contents of the file being turned into folders. Just want to mkdir for each item in the list.

link|improve this question
feedback

5 Answers

One way is to open the list of names in word and do copy and replace. Replace ^p with ^pmkdir this will replace all carraige returns (^p) with a carriage return and the mkdir command. Then save it as a bat and run it. There's def a cleaner way to do this if its going to be used over and over, but this is quick quick.

link|improve this answer
+1 - I like it. Quick, simple, easy, and it works. – Mark Henderson Sep 1 '09 at 0:08
I generally use Excel for generating batch files like this, but this method will work too. – mh. Sep 1 '09 at 9:20
feedback

Here you go:

for /f %d in (listfiles) do md %d

This makes a directory under the current directory for each line in a file called "listfiles" in the current directory.

If you saved the file as a .txt file, make sure to reflect that in the command.

for /f %d in (listfiles.txt) do md %d 
link|improve this answer
feedback

The code for /f %d in (listfile) do md %d is nice but if you want to use it in a batch file you need to add extra % to the variable. for /f %%d in (listfile) do md %%d

link|improve this answer
feedback

if you have powershell then
gc listfile | %{md $_}

link|improve this answer
feedback

Assuming list of names are stored in a text file called dirlist.txt, then the command should be like this:

for /F "tokens=1 delims= " %i in (dirlist.txt) do md %i

link|improve this answer
feedback

Your Answer

 
or
required, but never shown