Posted By

tclancy on 02/25/09


Tagged

files directory


Versions (?)

Python Directory Walk


 / Published in: Python
 

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

I always forget this.

  1. import os
  2. import sys
  3. fileList = []
  4. rootdir = sys.argv[1]
  5. for root, subFolders, files in os.walk(rootdir):
  6. for file in files:
  7. fileList.append(os.path.join(root,file))
  8. print fileList

Report this snippet  

You need to login to post a comment.