# list files in dir tree by recursion import sys, os from random import * from string import * def mylister(currdir): # Can edit the following for tailored searches allowed = ['doc', 'gif', 'htm', 'html', 'jpeg', 'jpg', 'mov', 'pdf', 'rtf', 'txt', 'xls', 'xml'] ideas = [] for file in os.listdir(currdir): # list files here path = os.path.join(currdir, file) # add dir path back if not os.path.isdir(path): fileType = lower(split(path,'.').pop()) if fileType in allowed: ideas.append(path) print path else: dirParts = split(lower(path),'_') if 'files' in dirParts: print path else: ideas = ideas + mylister(path) # recur into subdirs return ideas # Take the directory as argument, otherwise select all if __name__ == '__main__': seed() ideas = [] if len(sys.argv) > 1: ideas = mylister(sys.argv[1]) # dir name in cmdline else: ideas = mylister('.') # dir name in cmdline # Create html file with results of query f=open('ideas.htm','w') f.write('\n') f.write('
\n') f.write('