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


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.