Geoff Lang | 0e43546 | 2013-09-03 15:21:51 -0400 | [diff] [blame^] | 1 | import fnmatch |
| 2 | import os |
| 3 | import sys |
| 4 | |
| 5 | rootdirs = [ ] |
| 6 | filetypes = [ ] |
| 7 | |
| 8 | foundTypesArg = False |
| 9 | for i in range(1, len(sys.argv)): |
| 10 | arg = sys.argv[i] |
| 11 | if arg == "-types": |
| 12 | foundTypesArg = True |
| 13 | continue |
| 14 | |
| 15 | if foundTypesArg: |
| 16 | filetypes.append(arg) |
| 17 | else: |
| 18 | rootdirs.append(arg) |
| 19 | |
| 20 | for rootdir in rootdirs: |
| 21 | for root, dirnames, filenames in os.walk(rootdir): |
| 22 | for file in filenames: |
| 23 | for type in filetypes: |
| 24 | if fnmatch.fnmatchcase(file, type): |
| 25 | print os.path.join(root, file).replace("\\", "/") |
| 26 | break |