Python Directory Walk


/ Published in: Python
Save to your folder(s)

I always forget this.


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.