2 # Fixfiletypes - Set mac filetypes to something sensible,
3 # recursively down a directory tree.
5 # It will only touch extensions it feels pretty sure about.
6 # This script is useful after copying files from unix.
8 # Jack Jansen, CWI, 1995.
16 ('.py', 'Pyth', 'TEXT'),
17 ('.pyc', 'Pyth', 'PYC '),
18 ('.c', 'CWIE', 'TEXT'),
19 ('.h', 'CWIE', 'TEXT'),
20 ('.as', 'ToyS', 'TEXT'),
21 ('.hqx', 'BnHq', 'TEXT'),
22 ('.cmif', 'CMIF', 'TEXT'),
23 ('.cmc', 'CMIF', 'CMC '),
24 ('.aiff', 'SCPL', 'AIFF'),
25 ('.mpg', 'mMPG', 'MPEG'),
28 def walktree(name
, change
):
29 if os
.path
.isfile(name
):
30 for ext
, cr
, tp
in list:
31 if name
[-len(ext
):] == ext
:
32 fs
= macfs
.FSSpec(name
)
33 curcrtp
= fs
.GetCreatorType()
34 if curcrtp
<> (cr
, tp
):
36 fs
.SetCreatorType(cr
, tp
)
37 macostools
.touched(fs
)
40 print 'Wrong', curcrtp
, name
41 elif os
.path
.isdir(name
):
43 files
= os
.listdir(name
)
45 walktree(os
.path
.join(name
, f
), change
)
48 fss
, ok
= macfs
.GetDirectory('Folder to search:')
51 walktree(fss
.as_pathname(), change
)
53 if __name__
== '__main__':