Return to Snippet

Revision: 11963
at May 26, 2010 13:38 by tclancy


Updated Code
import os
import sys
fileList = []
rootdir = sys.argv[1]
for root, subFolders, files in os.walk(rootdir):
    for file in files:
        fileList.append(os.path.join(root,file))
print fileList

Revision: 11962
at May 26, 2010 13:22 by tclancy


Updated Code
for subdir, dirs, files in os.walk(rootdir):
    pass

# OR

for subdir, dirs, files in os.walk(STORAGE_PATH):
    for file in os.listdir(subdir):
        existing_file_path = os.path.join(STORAGE_PATH, subdir, file)

Revision: 11961
at February 25, 2009 14:00 by tclancy


Initial Code
for subdir, dirs, files in os.walk(rootdir):

Initial URL
http://mayankjohri.wordpress.com/2008/07/02/create-list-of-files-in-a-dir-tree/

Initial Description
I always forget this.

Initial Title
Python Directory Walk

Initial Tags
files, directory

Initial Language
Python