Different name, fashion's the same: Styledash is now the StyleList Blog!

AppleScript: Taking screenshots



Last week, Dave mentioned that you can change the file type used system-wide for screenshots. However, some people are afraid of using Terminal.app 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/ScriptEditor.app). 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).

Related Headlines

Reader Comments (Page 1 of 1)

Add your comments

Please keep your comments relevant to this blog entry. Email addresses are never displayed, but they are required to confirm your comments.

When you enter your name and email address, you'll be sent a link to confirm your comment, and a password. To leave another comment, just use that password.

To create a live link, simply type the URL (including http://) or email address and we will make it a live link for you. You can put up to 3 URLs in your comments. Line breaks and paragraphs are automatically converted — no need to use <p> or <br /> tags.

TUAW Features

back-to-school
Mac 101 ask-tuaw
Mac News
WWDC (251)
.Mac (66)
Accessories (652)
Airport (75)
Analysis / Opinion (1424)
Apple (1698)
Apple Corporate (580)
Apple Financial (200)
Apple History (51)
Apple Professional (54)
Apple TV (164)
Audio (450)
Bad Apple (131)
Beta Beat (155)
Blogging (87)
Bluetooth (19)
Bugs/Recalls (57)
Cult of Mac (879)
Deals (225)
Desktops (116)
Developer (282)
Education (110)
eMac (10)
Enterprise (147)
Features (412)
Freeware (399)
Gaming (397)
Graphic Design (38)
Hardware (1308)
Holidays (37)
Humor (589)
iBook (66)
iLife (240)
iMac (185)
Internet (340)
Internet Tools (1342)
iTS (982)
iTunes (823)
iWork (23)
Leopard (376)
Mac mini (112)
Mac Pro (54)
MacBook (206)
MacBook Air (83)
Macbook Pro (226)
MobileMe (47)
Multimedia (459)
Odds and ends (1489)
Open Source (282)
OS (940)
Peripherals (214)
Podcasting (183)
Podcasts (95)
Portables (198)
PowerBook (136)
PowerMac G5 (51)
Retail (612)
Retro Mac (50)
Rig of the Week (42)
Rumors (642)
Software (4459)
Software Update (428)
Steve Jobs (254)
Stocking Stuffers (50)
Surveys and Polls (98)
Switchers (114)
The Woz (35)
TUAW Business (257)
Universal Binary (281)
UNIX / BSD (61)
Video (908)
Weekend Review (84)
WIN Business (47)
Wireless (89)
Xserve (39)
iPhone/iPod News
iPhone (1789)
iPod Family (2118)
App Store (158)
SDK (29)
Mac Events
One More Thing (27)
Liveblog (2)
Other Events (226)
Macworld (489)
Mac Learning
AppleScript (4)
Ask TUAW (107)
Blogs (85)
Books (26)
Books and Blogs (62)
Cool tools (451)
Hacks (472)
How-tos (490)
Interviews (44)
Mods (191)
Productivity (591)
Reviews (114)
Security (167)
Terminal Tips (66)
Tips and tricks (575)
Troubleshooting (173)
TUAW Features
iPhone 101 (36)
TUAW Labs (4)
Blast From the Past (19)
TUAW Tips (150)
Flickr Find (38)
Found Footage (90)
Mac 101 (111)
TUAW Interview (31)
Widget Watch (198)
The Daily Best (1)
TUAW Faceoff (6)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Sponsored Links

The Unofficial Apple Weblog (TUAW) bloggers (30 days)

#BloggerPostsCmts
1Cory Bohon561
2Robert Palmer5544
3Steven Sande5115
4Mike Schramm270
5Erica Sadun251
6Michael Rose2330
7Mat Lu2110
8Dave Caolo210
9Giles Turnbull200
10Christina Warren1428
11Brett Terpstra120
12TUAW Blogger70
13Victor Agreda, Jr.511
14Jason Clarke21
15Scott McNulty20

Featured Galleries

DNC Macs
Macworld 2008 Keynote
Macworld 2008 Build-up
Apple Vanity Plates
DiscPainter
Crash Bandicoot Nitro Kart 3D
Macworld Expo 2007 show floor
Apple Texas Hold 'Em
The Macworld Faithful in Line

 

    Most Commented On (7 days)

    Recent Comments

    More Apple Analysis

    More from AOL Money and Finance

    Other Weblogs Inc. Network blogs you might be interested in: