import os root = os.getcwd() # get current working dir f_html = open('index_ul.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('\n') elif ( (os.path.isfile(root + subroot + '/' + item) ) & (subroot != '') ): f_html.write('
  • -' + item + '\n') print ' '*indent + item #scrive intestazione file html f_html.write('\n') f_html.write('\n') f_html.write('\n') f_html.write('\n') f_html.write('

    \n') buildtree(root,'',0) f_html.write('
    \nQuesto file stato automaticamente generato usando ') f_html.write('questo programma
    \n') # scrive chiusura file html f_html.write('

    \n') f_html.write('\n') f_html.write('\n') f_html.close()