Page 1 of 1

Changing "open with" application with Hazel rule?

PostPosted: Wed Jan 22, 2014 2:04 am
by roosterboy
Is there a way to have Hazel change the "open with" application for a file when a rule matches?

I want most of my PDFs to open in Preview. But any PDF that I add to a particular folder, I'd like to set to open in Acrobat XI Pro.

Presumably this would involve running a script on matched files, but I'll be damned if I can figure out how to script that.

So two questions...

a) how do I script that?

b) seems like a useful action for Hazel to have built in; how can I request it?

Re: Changing "open with" application with Hazel rule?

PostPosted: Wed Jan 22, 2014 4:21 pm
by Mr_Noodle
In the "Open" action, just click on the pop-up and select "Other...".

Re: Changing "open with" application with Hazel rule?

PostPosted: Wed Jan 22, 2014 5:25 pm
by roosterboy
Except that opens the file, which isn't what I want to do.

Maybe I wasn't clear in my initial question. I don't want to open files that match the rule; I want to set the application that will open them tomorrow or next week or a year from now, whenever I double-click on the file in Finder. Basically, as if I had opened the Info window for each matching file and manually set the open with dropdown but, y'know, without actually having to do that manually.

Used to be, in the pre-OS X days, we could set a file's creator code using AppleScript to do this. Using mdls on a file shows there's a kMDItemFSCreatorCode attribute but it doesn't seem to have much effect in my (admittedly limited so far) testing. As far as I've been able to figure out, that info is now stored in the com.apple.FinderInfo extended attribute, but I can't find any way to set it.

So is there any way to script this, which would mean I could include it in a run script action in Hazel?

Also, it seems like this would be a useful addition to the available actions in Hazel.

Re: Changing "open with" application with Hazel rule?

PostPosted: Thu Jan 23, 2014 4:13 pm
by Mr_Noodle
Ah, I see. Yes, you'll need to use a script to do that though I don't know off-hand the way to do that so you'll have to google around. I'll consider it as a built-in action though I'm not sure how common it is to make it a worthwhile addition.

Re: Changing "open with" application with Hazel rule?

PostPosted: Thu Jan 23, 2014 11:43 pm
by roosterboy
Cool, thanks.

I was able to get it done with Automator's Set Application for Files action. I tried it with an AppleScript using the default application property of System Events' file object but could not get it to work no matter what I tried or how I reworded it. Oh well.