import os
root = os.getcwd() # get current working dir
f_html = open('index.html','w')
def buildtree(root,subroot,indent):
listdir = os.listdir(root + subroot)
for item in listdir:
if os.path.isdir(root + subroot + '/' + item):
f_html.write(' '*indent + item + '
\n')
print ' '*indent + item
buildtree(root,subroot+ '/' + item, indent+3)
elif ( (os.path.isfile(root + subroot + '/' + item) ) & (subroot != '') ):
f_html.write(' '*indent + '- ' + item + '
\n')
print ' '*indent + item
#scrive intestazione file html
f_html.write('\n')
f_html.write('
\n') buildtree(root,'',0) # scrive chiusura file html f_html.write('
\n') f_html.write('\n') f_html.write('