1def findFiles(dir):
2 files = []
3 # remove a trailing slash if it exists
4 if dir[-1:] == "/":
5 dir = dir[0:-1]
6 # loop through files and directories
7 for x in os.listdir(dir):
8 if os.path.isdir(dir + "/" + x):
9 # list this dir also
10 files.extend(findFiles(dir + "/" + x))
11 else:
12 # add the file to the list
13 files.append(dir + "/" + x)
14 return files
15