use the following code to list the files in a dir tree
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
use the following code to list the files in a dir tree
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
RSS feed for comments on this post. TrackBack URI
[...] Original post [...]
Pingback by ownport.net » Blog Archive » recursive list files in a dir using Python — October 6, 2008 @ 5:32 pm |