Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import stat
- def walktree (top = ".", depthfirst = True):
- names = os.listdir(top)
- if not depthfirst:
- yield top, names
- for name in names:
- try:
- st = os.lstat(os.path.join(top, name))
- except os.error:
- continue
- if stat.S_ISDIR(st.st_mode):
- for (newtop, children) in walktree (os.path.join(top, name), depthfirst):
- yield newtop, children
- if depthfirst:
- yield top, names
- for (basepath, children) in walktree("C:/Users/Bussiere/Documents/docinfo",False):
- for child in children:
- print (os.path.join(basepath, child).replace("C:/Users/Bussiere/Documents/docinfo",""))
Add Comment
Please, Sign In to add comment