28 April 2014, 05:16
A reader of Mac Kung Fu recently got in touch asking if I knew of an app that would do the following:
- Quit all open files in all apps;
- Quit all apps except for one.
He wanted this because he found Mac OS X’s strategy of resuming open apps on boot-up/login to be unsatisfactory.
There’s a tip in the book that explains how to use AppleScript to quit all apps but it wasn’t as sophisticated as this. However, hacking together something to do the trick wasn’t difficult. As always when giving out AppleScript I should point out that I’m not an AppleScript expert or even a programmer (although, of course, this is what’s so great about AppleScript — it caters to people like me).
Here’s the script — just open AppleScript Editor and paste it in, then save it out as an app. This will quit all apps except Microsoft Word but you can change the name of that app for any other app in the first line of the code:
tell application "System Events" to set quitapps to name of every application process whose visible is true and name is not "Finder" and name is not "Microsoft Word" repeat with closeall in quitapps try tell application closeall to close every window end try quit application closeall end repeat