Using Python to find Type/Creator codes

It has been a while since I needed to know about old-style Mac Type/Creator codes, but today I wanted to search my hard drive for files of a specific type. I thought you used to be able to drag a file into the find file Type box and it would automatically assign the Type to the input box, but this no longer seems to be the case on OS X.

I thought about downloading some utility which would allow me to see the Type code of a file of the same Type as the one I was trying to find, but then I realized I could probably do it with Python, and I was right.

>>> MacOS.GetCreatorAndType('/Volumes/Stormbringer/Audio/New Sessions/Guitar Project/Guitar')
('MOUP', 'PERF')

I also find myself occasionally using the Python REPL to do things like perform some quick math, convert between a char and the ordinal of that char, and look up unicode glyph names and resolve them. Instead of downloading some specific program to do some task, I have access to this vast functionality space which I can use to create my own utilities simply by remembering the steps to perform.

1 comment:

Michael Hudson said...

I occasionally forget what using computers must be like for people who *don't* have access to this kind of thing... must be horrible!