Learn how to How to Relaunch Finder with AppleScript
When I made this site I had, kind of, a "plan"... I have ditched the "Plan". I have decided to do good and fun tutorials; for example, how to draw naked women with Illustrator and Photoshop. As I look at the keywords from the searches that lead to my site, I believe this site would be more use to people if I covered the basics of using Apple Computers before showing everyone how much "nicer" programs are when you really learn to use them; for example, using Illustrator and Photoshop to draw naked women. So, what is my point? this is the fourth tutorial and I am explaining how to restart Finder with "One Click" using AppleScript.
We are now going to look at the abosolute basics of using AppleScript. If you know the basics you can do cool things, like what I am about to show you, and amaze your windows-using friends by showing them your first "program" and you have only had your Mac a few weeks. you can even design your own Icon. I have not gotten to that tutorial yet. If you can't wait I posted a thread about it on Vshens, read that. Now back to amazing your friends...
Just before we get started... As in every tutorial on this site I have to warn you my computer is not set up "standard" I have my Dock on the left side of the screen and I have a "Clear" theme. This should not cause you any problems, you should know where your dock is and you should understand that not every one wants to have "Brushed Metal" as their default theme. If you have any questions, send me a mail through the contact form. Now that we have that out of the way.![]()
Preparing
Unlike my desktopbackground image switching script, you will not be needing to Enable the Script menu in your menu bar. We are going to make an Application. So open your Script Editor, you will find Script Editor.app in Applications/AppleScript. When it opens it will start a new "Untitled" Script for you.
Write the AppleScript
For those of you that just want the script, it is posted at the bottom of this page. For the rest of you let's take this step by step. AppleScript is pretty straight forward. I will write this statement by statement.
We will be running the command through and to Finder. So first we have to wake it up. The syntax is pretty simple, you can "read" it. The following line will "give focus" to Finder.
activate application "Finder" --gives Finder focus
Like I said, we can read that, activate application "Finder".
Next we tell an application that we are going to tell it something "tell application"" ";.
tell application "Finder" --selects application, activate finder
Again, that is readable.
Next, we tell it what we wanted to tell it, just directly.
quit --duh! delay 2 --finder needs some time to save it's state activate application "Finder" --restart Finder
We told "Finder" to quit, delay 2, and activate application "Finder". Also readable; Just read it. You May ask yourself, "why do I need the delay?" Well, finder needs a short delay to get ready to quit with out carshing everything else.
Oh Yeah, you have to now tell the application you have stopped talking to it.
end tell
If you were not writing along:
copy & paste
This script into the empty Script Editor window.
activate application "Finder" --gives Finder focus tell application "Finder" --selects application quit --duh! delay 2 --finder needs some time to save it's state activate application "Finder" --restart Finder end tell
Almost done. now click "Compile" at the top and then click "Run". You will see Finder Quit and, after a short delay, Restart.
Save as an Application
Now to Make it all work with just One Click we can just shove it into the Dock. So we make it an Application. Either, Press "Shift Command S" or Click "File" then "Save As..." you will see a Window, like the one displayed here. Shoose a Destination. Your desktop will do. Save it in Applications and you won't lose it. In the File Format field Select "application".
Finally Click "Save". Now Drag the application into your Dock. Like I mentioned before, you can change that icon. I will get to that later.
So, now you can Restart finder with just One Click.
... that was all.