AppleScript: Close All

One of the problems with having a todo list bigger than the the Eiffel Tower is that sometimes I have more applications open than my computer would like to handle. To clean my desktop I could use a Logoff / Login sequence, but that would interfere with Dropbox synchronization and therefore I opted to use an AppleScript that closes all windowed applications.

The close all script that I use is the following:

-- Insert Date and Time into your documents
-- @2010 David Rodrigues
set exclude to {"Finder"}
tell application "System Events"
	set end of exclude to displayed name of (info for (path to frontmost application))
	set app_list to name of every process whose visible is true
end tell
repeat with this_app in app_list
	if this_app is not in exclude then
		tell application this_app
			activate
			quit
		end tell
	end if
end repeat

Remember, put the script in the ~/Library/Scripts folder (don’t forget to activate the “Show Script…” in Apple Script Utility

I now have a much cleaner desktop…