A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/329956.html below:

batch mkdir using a file list

batch mkdir using a file list batch mkdir using a file listJeremy Jones zanesdad at bellsouth.net
Fri Sep 23 14:46:31 EDT 2005
DataSmash wrote:

>Hello,
>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:
>1144
>1145
>1146
>1147
>
>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 = file.read()
>print "Creating directory " + str(read)
>os.mkdir(str(read))
>
>Appreciate any help you can give!
>R.D.  Harles
>
>  
>
Untested code:

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


- JMJ

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4