]> granicus.if.org Git - python/commitdiff
Script to recursively change PYTH creators to Pyth
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 21 Feb 1996 15:27:24 +0000 (15:27 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 21 Feb 1996 15:27:24 +0000 (15:27 +0000)
Mac/scripts/FixCreator.py [new file with mode: 0644]

diff --git a/Mac/scripts/FixCreator.py b/Mac/scripts/FixCreator.py
new file mode 100644 (file)
index 0000000..f5213d0
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# FixCreator - Search for files with PYTH creator
+# and set it to Pyth.
+#
+import os
+import macfs
+import sys
+
+OLD='PYTH'
+NEW='Pyth'
+
+def walktree(name, change):
+       if os.path.isfile(name):
+               fs = macfs.FSSpec(name)
+               cur_cr, cur_tp = fs.GetCreatorType()
+               if cur_cr == OLD:
+                       fs.SetCreatorType(NEW, cur_tp)
+                       print 'Fixed ', name
+       elif os.path.isdir(name):
+               print '->', name
+               files = os.listdir(name)
+               for f in files:
+                       walktree(os.path.join(name, f), change)
+                       
+def run(change):
+       fss, ok = macfs.GetDirectory('Folder to search:')
+       if not ok:
+               sys.exit(0)
+       walktree(fss.as_pathname(), change)
+       
+if __name__ == '__main__':
+       run(1)
+       
+