#!/usr/bin/python
import os
def recurlist(p,level):
for item in os.listdir(p):
if os.path.isdir(os.path.join(p,item)):
newlevel = level + "--"
print newlevel + item + "(d)"
newpath = os.path.join(p,item)
recurlist(newpath,newlevel)
elif os.path.isfile(os.path.join(p,item)):
newlevel = level + "--"
print newlevel + item
p = raw_input("Please enter the path to recursively list: ")
recurlist(p,"")
import os
def recurlist(p,level):
for item in os.listdir(p):
if os.path.isdir(os.path.join(p,item)):
newlevel = level + "--"
print newlevel + item + "(d)"
newpath = os.path.join(p,item)
recurlist(newpath,newlevel)
elif os.path.isfile(os.path.join(p,item)):
newlevel = level + "--"
print newlevel + item
p = raw_input("Please enter the path to recursively list: ")
recurlist(p,"")
No comments:
Post a Comment