batch mkdir using a file list

Jeremy Jones zanesdad at
Fri Sep 23 20:46:31 CEST 2005

DataSmash wrote:

>I think I've tried everything now and can't figure out how to do it.
>I want to read in a text list from the current directory,
>and for each line in the list, make a system directory for that name.
>My text file would look something like this:
>I simply want to create these 4 directories.
>It seems like something like the following
>code should work, but it doesn't.
>import os
>file = open("list.txt", "r")
>read =
>print "Creating directory " + str(read)
>Appreciate any help you can give!
>R.D.  Harles
Untested code:

import os
for line in open("list.txt", "r"):


More information about the Python-list mailing list