Latest in Applescript

Image credit:

AppleScript: Taking screenshots

Cory Bohon

Last week, Dave mentioned that you can change the file type used system-wide for screenshots. However, some people are afraid of using to muck around with their Mac. In this week's AppleScript article, I am going to show you how to take screenshots and change their file type using an AppleScript.

The AppleScript
property N : 0
set N to N + 1
set picPath to ((POSIX path of (path to desktop)) & "Picture_" & N & ".png") as string
do shell script "screencapture -tjpg " & quoted form of picPath

Using the AppleScript
Open the ScriptEditor (/Applications/AppleScript/ Copy/paste the AppleScript into the script edtitor and click the run button at the top. You will hear the camera shutter sound and a picture will be taken and saved to your desktop.

This script comes in handy when you want to take a screenshot in a different format. To do this, just change the ".png" file type to whatever you might want (say, .jpg, .tiff, etc.). When you re-run the script, the new file type will be associated with the capture image.

Continue reading to learn how to save this script.

Saving the AppleScript
You can save this script as an application in order to quickly take screenshots in the file type you want. To save the script as an appliction:

  1. Select File > Save As
  2. Select "Application Bundle" from the "File Format" drop-down box
  3. Click the save button

Update: The script has been updated to include "-tjpg" for the "screencapture" shell script. This allows the image file type to be changed temporarily. Thanks to a commenter for pointing out this error with the script! To change the file type, just replace " -tjpg " with "-tpng" (or your favorite image type).

From around the web

ear iconeye icontext filevr