Pinterest Stumbleupon Whatsapp

applescript automatorIn part one of my introductory article Learn to Automate Your Mac with AppleScript [Part 1: Introduction] Learn to Automate Your Mac with AppleScript [Part 1: Introduction] Read More about Apple”˜s automation program, AppleScript, I explained how to basically access this application and use a few of the default scripts that come with every version of Mac OS X. In part two of this article I will explain how to use a few cool and practical automation scripts that you might find useful.

With the following instructions, I assume that you have read the overview in part one of this series.

Move To Folder

The following script, when activated, will put all the files on your desktop into a folder and name that folder “screenshots”, or whatever name you designate. I use this script because I take several screenshots a day for articles like this one.

  1. Launch AppleScript and copy and paste the following code in the editor.

    set folder_name to “screenshots”

    tell application “Finder”

    set archive_folder to make new folder at desktop ¬

    with properties {name:folder_name}

    move every file of desktop to archive_folder

    end tell

  2. Click the Compile button in the AppleScript toolbar. It should look similar to the script above. You can of course customize the label “screenshots”.
  3. To test this script, put some files (not folders) on your desktop, and then click the Run button in AppleScript. It should move those files into a folder and label it.
  4. Finally, save the script as an application and put it both in your Application’s folder and in your dock and run as needed. This script saves you a few steps and clicks when you’re working at your computer.

applescript automator

Folder Action Script

One of the best kind of automations is folder actions 2 Useful Tips For Organizing Electronic Files [Mac Only] 2 Useful Tips For Organizing Electronic Files [Mac Only] Read More because since we typically move stuff into folders anyway we might as well use a few to automate a redundant task or two.


This automation will open your Shared folder when one or more items are dropped into it.

  1. Copy and paste the following code in the AppleScript editor:

    on adding folder items to theFolder after receiving theItems

    tell application “Finder”

    make new Finder window to folder “Shared” of folder “Users” of startup disk

    set position of Finder window 1 to {500, 236}

    end tell

    end adding folder items to

  2. Compile the script to make sure it’s OK. Save it in your User Library > Scripts  > Folder Actions folder. If this folder doesn’t exist, you can simply create one. You can title it something like, “OpenShareFolder“.
  3. Now click on the AppleScript icon in your menu bar (this was covered in part one of the article) and select the Folders Action folder.
  4. applescript automator

  5. Select and run the Enable Folder Actions script so that folder actions will work on your Mac.
  6. Now go back to that same folder and select and run Attach Script to Folder.
  7. It will open a list of Folder Actions on your computer. Find and select the folder action script you just saved. Click OK.
  8. folderactions.png

  9. Next you will be prompted to choose a folder to attach the selected script to. In this case, select your Shared folder on your Mac. Click Choose.

Now whenever an item is dropped into your shared folder, the attached AppleScript will open your folder for you.

These are just a few examples of what can be done with AppleScript. Let us know how they work for you. In the final part of this series, I will share some free resources for learning more about AppleScript.

Leave a Reply

Your email address will not be published. Required fields are marked *