All pastes #971752 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-04 23:10 UTC
rendered paste body
# Import libraries.
import os, os.path, sys

# Parse commandline settings.
if not len(sys.argv[1:]):
    print "build-list builds a list of the files and directories"
    print "searching recursively on path given."
    print "Usage: build-list /directory/ [filename]"
    exit(1)

# Assume stdout, create file if needed.
filelist = sys.stdout
if len(sys.argv[1:]) == 2:
    filelist = open(sys.argv[2], "w")

# Ok, walk through.
for root, dirs, files in os.walk(sys.argv[1]):
    for name in files:
        filelist.write(os.path.join(root, name,'\n'))