Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Using Applescript to execute a Terminal command

I've looked at the possible answers that come up when I ask this question here, but none really fit my question.


I want to automate the Terminal command that cleans out obsolete entries in my right-click "Open with" menu, which I have to do often. Rather than copying the command each time I want it, then opening Terminal, pasting it in, etc., is there a way to automate this with Applescript? Thanks!

iMac, OS X Mavericks (10.9)

Posted on Feb 6, 2014 8:40 AM

Reply
24 replies

Feb 6, 2014 8:53 AM in response to Niel

Thanks for the fast reply, Niel. I understand this is a newbie Applescript question, but over the years I have just never used Applescript and other than this one thing, probably won't again. So rather than take hours to learn it, I hope you don't mind the additional question regarding this. Do I just put the following into the main Applescript editor?


do shell script "ls -l ~"


/System/Library/Frameworks/CoreServices.framework//Versions/A/\

Frameworks/LaunchServices.framework/Versions/A/Support/lsregister \

-kill -r -domain local -domain user;

killall Finder

Feb 6, 2014 10:57 AM in response to Niel

Well, that was scary! I ran the Applescript and it didn't give me any errors, but my desktop went completely blank...no icons at all...for over two full minutes! It finally came back, but I think I'll forget about automating it. When I run this command in Terminal, it simply blinks the desktop icons off and then right back on again as it kills Finder and rebuilds the desktop.

Using Applescript to execute a Terminal command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.