Jack Jansen | 2258699 | 1996-02-21 15:27:24 +0000 | [diff] [blame] | 1 | # |
| 2 | # FixCreator - Search for files with PYTH creator |
| 3 | # and set it to Pyth. |
| 4 | # |
| 5 | import os |
| 6 | import macfs |
| 7 | import sys |
| 8 | |
| 9 | OLD='PYTH' |
| 10 | NEW='Pyth' |
| 11 | |
| 12 | def walktree(name, change): |
| 13 | if os.path.isfile(name): |
| 14 | fs = macfs.FSSpec(name) |
| 15 | cur_cr, cur_tp = fs.GetCreatorType() |
| 16 | if cur_cr == OLD: |
| 17 | fs.SetCreatorType(NEW, cur_tp) |
| 18 | print 'Fixed ', name |
| 19 | elif os.path.isdir(name): |
| 20 | print '->', name |
| 21 | files = os.listdir(name) |
| 22 | for f in files: |
| 23 | walktree(os.path.join(name, f), change) |
| 24 | |
| 25 | def run(change): |
| 26 | fss, ok = macfs.GetDirectory('Folder to search:') |
| 27 | if not ok: |
| 28 | sys.exit(0) |
| 29 | walktree(fss.as_pathname(), change) |
| 30 | |
| 31 | if __name__ == '__main__': |
| 32 | run(1) |
| 33 | |
| 34 | |