Going through folders...
Andrei Kulakov
ak at silmarill.org
Mon Apr 15 20:48:51 EDT 2002
In article <mailman.1018913559.19895.python-list at python.org>, FREDRIK
HULDTGREN wrote:
> I want to go through a catalogue structure and make a textfile that
> lists the files in each catalogue/undercatalogue. I know that there is
> a function for doing this somewhere, I just can't remember what it is
> right now... all help is appreciated...
>
> /fredrik
import os
f = open("filelist.txt", 'w')
def visit(arg, dirname, names):
f.write(dirname + '\n')
for name in names:
f.write("\t%s\n" % name)
os.path.walk(path, visit, None)
where path is path to walk through..
- Andrei
>
>
--
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org
More information about the Python-list
mailing list