Download the new Switched app for your iPhone

Skip to Content

Autoblog's live coverage of the 2010 Detroit Auto Show
AOL Tech

applescript posts

Filed under: Apple

SDK devsugar: Re-signing applications

TUAW's devsugar series helps introduce developers to tools and tricks that they might not yet be familiar with. Today's tip centers on signing already-compiled and already-signed applications with a new custom signature.

A while back, I posted about a way to sign already-compiled applications with your personal credentials in order to better allow developer-to-developer distribution. By re-signing an application, it allows you to install it on any of the devices you have registered to your account at Apple without having to go through the fuss and bother of normal ad-hoc distribution. In addition, it makes it easier to develop applications on a contractor's machines, to ship them to a client, and then have them signed and shipped to App Store using the client's identity.

A basic command-line solution is as follows. It calls codesign (found in /usr/bin) to sign the application, using the default keychain item that matches "iPhone Developer". It's a handy script, especially for informal beta distributions.

#! /bin/bash

export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate

codesign -f -s "iPhone Developer" $1

There are, however, several problems with this approach. First, it assumes you only want to sign with development (typically "Debug build") credentials. That's not going to work if you need to re-sign for distribution. (Solution? Change iPhone Developer to iPhone Distribution). Second, it assumes you only have one developer or distribution profile in your keychain. (Solution? Change iPhone Developer, for example, to iPhone Developer: Company Name to exactly match just one keychain entry.) Third, it assumes the person doing the re-signing knows how to use a command line. For that, the solution is a little more complicated.

Recently, this topic came up on a developer e-mail list that I moderate: how do you make it easier for a non-technical client to re-sign an application, normally for distribution. As a solution, I put forth the proposal that one could embed the above shell script behavior into an AppleScript droplet. After consulting with a few colleagues, and gathering their requirements, I decided to give the project a try. I built an AppleScript application that signs any application dropped onto it.

You can find a working copy of the application at my website. App Signer iterates through any apps dropped onto it, checks to ensure whether each file (or bundle, really) ends with an ".app" extension, and then attempts to sign those files using /usr/bin/codesign.

Users can choose to sign with Developer credentials, Distribution credentials, or select Other to open a prompt and enter text for keychain disambiguation. (See the screen shot at the top of this post for an example of the disambiguation dialog.) The application displays results for each application, one at a time.

Please note the following caveats:
  • I make no attempt to guarantee that the app dropped onto this utility is actually an iPhone app (rather than, say a Macintosh application).
  • When working with on-device keychains, the identity used to sign the application has to match the application id set forth in the Info.plist file for the application, otherwise keychain access will fail.
  • This is a free application. It is offered under the BSD license. Use it at your own risk. Credit always appreciated. The open source github repository for App Signer can be found here.
  • To create the application, open the AppleScript source in Script Editor and choose File > Save As > File Format: Application.

Filed under: Software, How-tos, Productivity

Send tweets automatically during a Keynote presentation with Keynote Tweet

Imagine if, as Steve Jobs moves through each slide of his Keynote presentation, he also has the telepathic powers to automatically tweet information related to the slide.

But even the almighty Steve Jobs can't do that.

Fortunately for him, there's Keynote Tweet. An open source AppleScript app, Keynote Tweet will automatically tweet the text from your presenter notes (accessible by clicking on "view" and selecting "show presenter notes").

Keynote Tweet was exposed to me while reading a piece by IDEO Labs' Gentry Underwood, who highlights the idea of large presentations increasingly occurring within the context of a backchannel in which audience members are responding to what's being presented.

Getting Keynote Tweet up and running is fairly straightforward. Simply download the app, and then add the following entry into the Keychain Access app:

  • Keychain Item Name: http://twitter.com
  • Account Name: Your email address
  • Password: Your Twitter password

Now, with the Keynote Tweet app running, any text between the [twitter] and [/twitter] tags will automatically tweet when that slide is displayed (while in slideshow mode).

For example, "Jay Leno lacks the charm, wit and red headedness of Conan O' Brien" will be tweeted the moment I reach the slide showing the percentage of people that hate Jay Leno.

Keynote Tweet is available as a free download here.

[via IDEO Labs]

Filed under: Features, Troubleshooting, Ask TUAW

Ask TUAW: Automatic file sorting, Disk Utility, iPod battery replacement, and more

Welcome back to Ask TUAW, our weekly troubleshooting Q&A column. This week we've got questions about automatically sorting downloaded files, using Disk Utility to change partitions and format external drives, using a KVM in a multi-platform environment, replacing an iPod touch battery, and more.

As always, your suggestions and questions are welcome. Leave your questions for next week in the comments section at the end of this post. When asking a question, please include which machine you're using and what version of Mac OS X is installed on it (we'll assume you're running Snow Leopard on an Intel Mac if you don't specify), or if it's an iPhone-related question, which iPhone version and OS version you have.

Continue readingAsk TUAW: Automatic file sorting, Disk Utility, iPod battery replacement, and more

Filed under: Software, AppleScript

Sal Soghoian talks Automator use in education

Total Apps has published a nice guest post from Sal Soghoian, Apple's Production Manager for Automator, intended for teachers. He describes how educators have a limited amount of instruction time with the kids, and even less for maintenance tasks like making sure the proper software is installed, that students are on the proper web page, and so on.

Sal wants to help, and points out a number of links useful to anyone (not just teachers) who wants to automate these repetitive and often time-consuming tasks. Best of all, he shares a link to The Teacher's Helpers (scroll down a bit), which is a free collection of Automator actions specifically written to assist teachers with Macs in their classrooms.

If you've been put off by AppleScript, give Automator a try. Its drag-and-drop interface is much easier to use.

Filed under: How-tos, Tips and tricks, iTunes, AppleScript

Batch move your playlists to an iTunes folder

Folders, which have been a feature of iTunes since iTunes 5.0, serve as a means to better organize your music. For example, you could create genre- or artist-based folders with corresponding playlists nested within them. But moving playlists into folders isn't the most fun thing, and can be especially time consuming if you're going to be moving a bunch. Fortunately, the "Move Playlists to Folder" script provides a means for you to easily move multiple playlists over to a specified folder in iTunes.

First, download and install the script: the file should reside in your [username]/Library/iTunes/Scripts/ folder. After successful installation, the script will now appear as an item in the scripts menu. If you didn't already have any scripts installed, the script menu allows you to access and run scripts for a specific app.

This AppleScript, along with a host of many other iTunes script goodies, is available as a free download at Doug's Scripts. However, Doug would also be more than happy if you were generous enough to donate a buck or two to help buy him a latte.

Filed under: Cool tools, Snow Leopard

Snow Leopard Services in practice: Amazon S3 uploader

I stumbled upon a great example of the Snow Leopard Services that I've been drooling over. The S3 Upload Service by August Lilleaas is available as a workflow which can be opened in Automator, so you can examine its inner workings. It uses AppleScript and Ruby, easily passed back and forth thanks to Automator's building-block-style workflow. It lets you upload a publicly-accessible file to an S3 bucket, and copies the URL into your clipboard upon successful upload.

The workflow requires that you at least have RubyGems installed, and have an Amazon S3 account set up, but it will handle the rest. It asks for your S3 credentials with an AppleScript popup, which has the unfortunate side effect of not being able to be forced to the front very easily and tends to get lost behind other windows. There are workarounds to that, but no way to keep it on top once it's up. It looks possible to build custom nibs for your services, so I might play around with making a general-purpose utility panel popup to fill the void in my own projects.

In the process of rolling my own Services in Snow Leopard, I've definitely found some limitations, but I'm having fun working around them. This one is a great example of passing results -- returned from different languages -- and processing them, all within Automator. It's not super-polished -- your mileage may vary -- but a big thanks to August for putting it out there for the rest of us to play with!

Filed under: Software, Features, How-tos, Tips and tricks, Internet Tools, AppleScript

Use iCal to tweet automatically

Recently, the question came up of how to automatically "tweet" a birthday message to a friend or loved one on their special day. After thinking on this question for some time I finally came to a solution. As it turns out, intrepid TUAW blogger Dave Caolo wrote a Mac 101 article all about attaching AppleScripts to iCal events. Additionally, Brad Linder over at Download Squad put together a nice little tutorial for posting to Twitter via the command line.

It wasn't obvious at first, but these two articles together formed a dynamic duo of birthday tweeting proportions. If, dear reader, you are interested in setting up a system for sending out some birthday tweets then follow along as we travel the mysterious world of iCal events and command line tweeting. Read on for a somewhat technical tutorial on how to set up some pre-scheduled tweeting goodness. (If you're looking for a service to take care of all this for you, here you go.)

Continue readingUse iCal to tweet automatically

Filed under: How-tos, iTunes, AppleScript

Lyric fetchin' lovin': how to batch fetch lyrics with GimmeSomeTune and Needle Drop

One neat little thing about the iPod and iPhone family of devices is their ability to display lyrics -- supported by all iPod nanos as well as the iPhone/iPod touch, and iPod Classic 5th generation and higher. On the iPhone and iPod touch, lyrics show up when a song is loaded (and can be re-displayed by tapping on the screen while a song is playing); while on the iPod nano, pressing the center button several times while a song is playing will cycle you through to display lyrics.

But the real issue isn't so much about displaying lyrics as much as it is obtaining them. PearLyrics was once my tried and true favorite way of getting lyrics, but it passed away some time ago.

Continue readingLyric fetchin' lovin': how to batch fetch lyrics with GimmeSomeTune and Needle Drop

Filed under: Software, How-tos

Great beginner's guide to AppleScript

Many years ago I started playing with AppleScript. For some reason, it failed to hold my attention, though I know you can do many cool tricks with it. Perhaps I'd still be at it if I had found an overview like the one posted at AppStorm.

This well-written guide starts with the basics and builds from there. I've seen entirely too many AppleScript guides that either go from the Tell statement right to masters-level stuff or that end entirely after creating the obligatory "Hello, world!" script.

Joshua, writing for AppStorm, covers variables, accessing dictionaries and walks readers through the creation of a handy Mail script. It's not comprehensive, of course, but just right as an introduciton. Check it out and get scripting.

Filed under: How-tos, Podcasts, Apple, AppleScript

iTunes 101: How to prevent podcasts from spoiling

Like milk, podcasts will spoil if left unused for a period period of time -- at least in the mind of iTunes. iTunes will automatically unsubscribe from a podcast that hasn't been listened to within the last 5 updates, and more than 5 days have passed since an episode was played.

The rationale, as Apple states in the documentation for podcast providers, is to "minimize unnecessary bandwidth costs for both the user and the podcaster," as well as making it more likely that episode downloads align with the actual plays of the episode.

But I like the option of being current on all my podcasts, as well as being selective about which episode(s) I want to listen to. And being the rebel that I am -- using a two button mouse in 2001 while everyone else was still control-clicking -- this means that I will sometimes not listen to a podcast within these set parameters.

In the past, iTunes would keep me in check by forcing me to manually click on the exclamation mark next to each podcast to resume updating the podcast. Needless to say, this became a chore after the 10th click. You can also select all your podcasts, right-click and choose "Update Podcast" to force a global update, but why do three steps when AppleScript is there to reduce those to one?

iTunes will keep me in check no longer, as Doug Adams (of Doug's Scripts fame) provides a solution for this issue with his Update Expired Podcasts v2.0 AppleScript -- which batch updates each of your podcasts. You could even set up an iCal alarm that runs the script every day to force a fresh set of podcasts.

Update Expired Podcasts v2.0 (download link) is donationware, and is available for download at Doug's Applescripts for iTunes site (link). It's finger clickin' good.

Filed under: Software, Security

Meerkat 1.2, 100% more AppleScript support

If you work from non-secure networks (coffeehouses, airports, hotels, etc.), or if you've ever wanted to bypass a firewall (YouTube or TUAW blocked at work?) you may be familiar with SSH tunneling. It's come up more than once here on TUAW. It allows you to conduct your Internet business through a secure proxy and makes the process transparent (once you set it up, you don't have to think about it). It's typically handled via a shell command, but some GUI-based programs can make life a lot easier -- both for the less technically-inclined, and for those who want to handle multiple tunnels and automation.

Enter Meerkat, the SSH tunnel tool with the friendly face. I mentioned Meerkat about a year ago, and apparently things have been busy at the Code Sorcery Workshop since that release. The latest version of Meerkat -- version 1.2 -- sports an array of new features, from AppleScript support to a command line utility, as well as improvements to existing features like Bonjour sharing and the tunnel editing interface. I've been using the previous version for quite some time now, and I can say that this version adds some great features to an already great application.

AppleScript support means automation, and Meerkat plays well with location managers like NetworkLocation (a plugin is available on the Meerkat page), or any location manager which can run AppleScripts or shell commands. With such a setup, you can have your system automatically detect a change in networks and set up specific tunnels depending on your location. I won't go into the details of location managers right now, but it's something to look into for laptop owners on-the-move.

Additional features, including Application Triggers, Bonjour support and automatic reconnect for dropped tunnels all make Meerkat a valuable tool. At a current price of $19.95US, Meerkat provides features for a spectrum of users, from the Tunnel Setup Assistant for newbies, to advanced automation possibilities for veteran SSH'ers. I'd be negligent if I didn't mention at least one similar app in the freeware realm: SSHTunnel is a nice, easy-to-use GUI for setting up and managing tunnels. It lacks some of the automation and integration capabilities, but is a definite must-see if you're not ready to fork out for something more full-featured.

A trial of Meerkat is available for download, and a license can be purchased for $19.95US.

Filed under: Features, How-tos, AppleScript

AppleScript: Exploring the power of Folder Actions, part III

So far in this AppleScript feature we've covered what folder actions are and how to create them. In this AppleScript post, I'm going to tell you how to create your own custom scripts and add them to your folder actions list.

If you work with file permissions a lot, then you know how crazy it can get when you need to change a ton of files to their correct permission types. With this AppleScript folder action, you can easily change the permissions just by dragging and dropping files in their correct folder.

Creating the Script
To get started, we'll open the Script Editor (located in /Applications/Utilities). Once you have the editor opened, copy/paste the following script:

on adding folder items to this_folder after receiving added_items
tell application "Finder"
set fold_name to the name of this_folder
try
repeat with i from 1 to number of items in added_items
set new_item to item i of added_items
set the item_path to the quoted form of the POSIX path of new_item
do shell script ("/bin/chmod -R +r " & item_path)
end repeat
end try
end tell
end adding folder items to

This script will change the dropped files to a permission of "0644" meaning that everyone can read the file. For information about chmod and command line permissions strings, visit the Wikipedia page.

Continue reading to learn more about this AppleScript and folder actions.

Continue readingAppleScript: Exploring the power of Folder Actions, part III

Filed under: Features, AppleScript

AppleScript: Exploring the power of Folder Actions, part II

In the last AppleScript post, I mentioned some of the useful ways to create Folder Actions, and showed you how to use one of the built-in scripts to perform a pretty useful action. In this AppleScript post, we'll dive into the built-in scripts in more detail, and I will tell you how each of them works.

Once you create a new folder action (as we did in the last tutorial), you will have a pop-up dialog asking if you would like to attach an Apple-created script. There should be around 13 preinstalled on your Mac. Now let's go through each of them, and see what they will do when attached:

Add-new item alert.scpt - This included script, which we covered in the last post, allows you to get a pop-up dialog upon dropping files in the attached folder. So, if you were to drop file x into the folder, a dialog would display a message that file x was just dropped in there. This script is great for networked folders, as you get a dialog when someone drops something in there.

Close-close sub-folders.scpt - This script will, when a file is dropped in the attached folder, close all opened Finder windows associated with that folder and subfolders. So, if you have that folder opened, or another subfolder within that folder, when you drop a file into it the script will close those opened Finder windows. You can use this script to tidy up your screen.

Convert-PostScript to PDF.scpt - If you have a PostScript file type (i.e. eps or ps files), then you can enable this folder action. When you drop a PostScript file on it there will be two folders created, one called "Original" and the other called "PDF." This folder action will take those PS files and turn them into PDFs for your instant viewing pleasure. You can use it in your workflow to easily convert from PS to PDF.

Read on to learn about even more built-in folder action scripts.

Continue readingAppleScript: Exploring the power of Folder Actions, part II

Filed under: Features, AppleScript

AppleScript: Exploring the power of Folder Actions, part I

Welcome to Part I of this mini AppleScript feature on creating useful folder actions. We'll have more posts on this topic coming up, but for now, let's introduce what a folder action is. Have you ever wanted to just drop a file into a folder and have something magically happen? Say, have a file printed, whisked to a remote site via FTP, or perhaps have an image be automatically flipped from horizontal to vertical? With Mac OS X's built-in folder actions, you can easily do this with a simple drag and drop.

Creating the folder
First, let's talk about how we can enable these "magical folders" that perform actions on files dropped within them. For this example, I'll show you how to make a folder on your desktop that, when a file gets dropped into it, will display a dialog letting your know that the file was placed there.

Continue readingAppleScript: Exploring the power of Folder Actions, part I

Filed under: Terminal Tips, AppleScript

Revisiting the randomized signature AppleScript, now with API goodness

When I shared an AppleScript last week which created randomized signatures using TextExpander, I promised to revisit it when the iheartquotes.com API started working again. It's working right now, but it seems to go up and down; check this link before you try the script and make sure you get a quote, not an error message.

As before, when used with a TextExpander snippet set to the AppleScript type, this script will provide a random quote, this time pulling it from the Internet rather than our own list. The script is essentially the same, so I'm only going to explain the part which changed; visit the previous article for a rundown on the rest:

set _date to do shell script ¬
"date +'Sent on %A, %b %d at %l:%M %p'|tr -s ' '"

set _quote to ""

try

set _quote to do shell script "curl -s \\
'http://www.iheartquotes.com/api/v1/random?source=macintosh&max_lines=4'"

set {astid, AppleScript's text item delimiters} ¬
to {AppleScript's text item delimiters, return}
set _quote to paragraphs 1 through -3 of _quote as string
set AppleScript's text item delimiters to astid

end try

set _out to "
-Brett

" & _date & "
________________________________
Brett Terpstra | myemailaddress@mywebsite.com
The Unofficial Apple Weblog | http://www.tuaw.com

" & _quote

return _out

The curl call

Here's the part which makes this more interesting than it was before:

set _quote to do shell script "curl -s \\
'http://www.iheartquotes.com/api/v1/random?source=macintosh&max_lines=4'"

First off, that really should be all one line, but is split here for formatting purposes. You can remove the double backslash (\\) and merge the lines together if you like. What this does is use AppleScript's ability to run shell scripts (Unix commands) to make a curl call to retrieve a response from the iheartquotes API. Note the "try" statement surrounding that section; it will just return our regular signature without the quote if anything goes wrong. If it gets a response, it stores it in a variable (_quote) and then trims off the last line, like this:

set {astid, AppleScript's text item delimiters} ¬
to {AppleScript's text item delimiters, return}
set _quote to paragraphs 1 through -3 of _quote as string
set AppleScript's text item delimiters to astid

The first two lines (actually one line) are shorthand for setting "AppleScript's text item delimiters" -- the character that AppleScript uses to separate text items in a block of text -- to the return character and store the current text item delimiter in a variable so we can restore it with the last line. Using the paragraphs command, which automatically uses the return key to separate paragraphs, we turn the quote into a list of paragraphs, starting with the first and ending with the third from last. This is because the last two "paragraphs" are always an empty line and a permalink (even if you use the API's parameters to turn off the permalink). The last part of that line, "as string", is where the text item delimiters come into play, putting the list items back together with a return after each one, reconstructing the original formatting.

Note: You could do the same thing by adding |sed -n '$!p' to the end of the do shell script line, right before the last double quote. I suppose you might as well, as long as you're dipping out to the shell anyway ...

From there it's the same as before, just building a final output string from the pieces we've created. This method provides a much wider variety of randomized signatures than constructing your own list by making use of a small section of the wide array of data on the interwebs. The use of curl in an AppleScript can open a lot of possibilities, such as posting to Twitter in various ways. or shortening urls on the fly. Have fun.

Tip of the Day

Want to drag a file to another folder and copy it instead of moving it? Press the Option key when you drag that file and it'll be duplicated rather than moved entirely.

Follow us on Twitter!

TUAW [Cafepress] 

Featured Galleries

DNC Macs
Macworld 2008 Keynote
Macworld 2008 Build-up
Google Earth for iPhone
Podcaster
Storyist 2.0
AT&T Navigator Road Test
Bento for iPhone 1.0
Scrabble for iPhone
Tom Bihn Checkpoint Flyer Briefcase
Apple Vanity Plates
Apple booth Macworld 07
WorldVoice Radio
Quickoffice for iPhone 1.1.1
Daylite 3.9 Review
DiscPainter
Mariner Calc for iPhone
2009CupertinoBus
Crash Bandicoot Nitro Kart 3D
MLB.com At Bat 2009
Macworld Expo 2007 show floor

 

Our Writers

Victor Agreda, Jr.

Programming Manager, AOL Tech

RSS Feed

View more Writers

More Apple Analysis

AOL Radio TUAW on Stitcher