Publishers of technology books, eBooks, and videos for creative people

Home > Blogs > Using AppleScript to control the Finder, Five AppleScript Tips in Five Days

Using AppleScript to control the Finder, Five AppleScript Tips in Five Days

Posted January 5, 2009

Topics: Apple, Operating Systems, Productivity

AppleScript is an easy-to-learn scripting language for the rest of us that is available on every Macintosh computer sold in the last decade and a half. You can write a simple AppleScript script in just a few minutes to save hours of drudgery later by automating a complex repetitive task. Once you've written the script, you only have to double-click it any time you need to get the job done.

Most applications are scriptable by design, including the Finder. To see how easy it is to understand an AppleScript script, consider this useful example that controls the Finder. Like most AppleScript scripts, it looks pretty much like plain English. You can run it every time you want to set up your Mac's desktop according to a standard starting configuration.

   tell application "Finder"
      close every window
      open home
      tell the front Finder window
         set toolbar visible to true
         set the sidebar width to 135
         set the current view to column view
         set the bounds to {36, 116, 511, 674}
      end tell
      open folder "Documents" of home
      tell the front Finder window
         set toolbar visible to false
         set the current view to flow view
         set the bounds to {528, 116, 1016, 674}
      end tell
      select the last finder window
   end tell

You can click this link to open the script in the Script Editor window: Script 1.37

We call this the Desktop Setup Script, Script 1.37 in our book Apple Training Series, AppleScript 1-2-3. Read Chapter 1 for more useful information about getting started with AppleScript, including how to change this script to suit your personal preferences. You can read Chapter 1 on Apple's AppleScript Web site.

To learn more about AppleScript, such as how to script applications that are not scriptable by design, return to this blog each day this week for new tips from our book Apple Training Series: AppleScript 1-2-3.

Comments

comments powered by Disqus