Thursday, July 3, 2008

recursive list files in a dir using Python

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

3 comments:

ownport.net » Blog Archive » recursive list files in a dir using Python said...

[...] Original post [...]

Kenny Meyer said...

Hey, this is simple but perfect..!

Serrano Pereira said...

This is just what I was looking for! So simple and it works like a charm.. thanks!