Set default app for file type via Applescript?

After reading a lot of discussions on this subject, I think the answer is “No,” but people here tend to know a lot, so I thought it was worth asking again:

Is it possible to set the default application for a filetype through Applescript? I want to write a script that will (for example) set the default application for .TXT files to TextWranger (instead of TextEdit), the default application for .DOC files to OpenOffice.org (instead of Word), the default application for files with the creator code XYZA to some other application, etc., etc. (These are only EXAMPLES to show the kind of thing I’m trying to do - I’m looking for a general technique that can be used for many file types.)

I know that I can do this slowly by using the RCDefaultApp preference pane, or by selecting a file and using Get Info…, Open With, and Change All. But is it possible to write an Applescript that will do it for me in a single operation?

Many thanks for any advice on this question.

Hi,

No clue if AS can do this but a talented develper released a cli-util that specifically does precisely what you’re looking for:

http://github.com/AlanQuatermain/SetAppAffinity

Thank you! That looks like exactly what I need - but, unless I’m missing something, there isn’t a working utility yet - only source code. Or am I missing something obvious??