Skip to Content

Submit your nominations for the Luxist Awards' Best in Decor
AOL Tech

Script posts

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: Cool tools, TUAW Tips, AppleScript

Random Signatures with TextExpander and AppleScript

TextExpander, a $29.95US utility which inserts snippets of text or images when you type a preset string of characters, has long been a TUAW favorite. I only recently learned that it can run AppleScripts within a snippet, which opened up a world of fun for me. Here's a quick script demonstrating how AppleScript can be used to randomize quotes within your email signature.

Create a new TextExpander snippet and set the content type to "AppleScript." Copy and paste the code that follows into the snippet content box. I'll run through what it does in at the end.

Read on for the script!

Continue readingRandom Signatures with TextExpander and AppleScript

Filed under: Features, How-tos

Mac Automation: saving Automator workflows

Now that you've been introduced to Automator, let's let's get into the "nitty-gritty." In the previous Automator post, we learned how to make a workflow that would take photos from your camera, import them into iPhoto, then allow you to e-mail them. Let's look at the three ways in which you can save this workflow for later reference.


Workflow File
You can save the workflow as an actual Automator workflow file by clicking File > Save; choose "workflow" from the format drop-down menu. By saving as an Automator workflow all of your actions are preserved, and when you re-open the file, you will be presented with your workflow just as you left it. This is a great way to save your workflow for editing later on.


Continue readingMac Automation: saving Automator workflows

Filed under: Features, How-tos

AppleScript: Finder commands

Now that you've mastered the tell command, it's time to introduce some of the other AppleScript commands that you may encounter.

Location command
This command will allow you to open a specific location (either on your Mac or on a web server). This command is most often used with the Finder. For instance, if you wanted to open "www.tuaw.com," then you would type:

tell application "Finder" to open location "http://www.tuaw.com"

Remember, when dealing with an application always include quote marks around the application name. When you're typing a URL, be sure to include the prefix (HTTP:, AFP:, FTP:, etc.) and include quote marks around the URL. You can also tell a specific web browser to open the URL:

tell application "Safari" to open location "http://www.tuaw.com"

However, if you use the Finder version of the script, it will open your default browser.

Continue readingAppleScript: Finder commands

Filed under: Features, How-tos

AppleScript: the Script Editor

Before you can build your first AppleScript you need to know some basics: what a script-able application is and how to use the Script Editor.

Script-able Applications
Basically, script-able applications are applications in which the developer has included a set of "instructions" that the Script Editor understands and can use. Some apps are not script-able but most Apple apps are and, of course, Mac OS X itself is script-able.

The Script Editor
The Script Editor is a very simple application, but it allows you to do some very powerful things. The Script Editor is located in your Applications folder (Applications : AppleScript : Script Editor.app) by default. The editor has a simple interface with a prominent text entry area. It also has 5 buttons in the toolbar; for now we will only focus on the "Run" and "Stop" buttons. The run button will run the currently typed script, and the stop button will cancel a running script.

Continue readingAppleScript: the Script Editor

Filed under: Analysis / Opinion, Hacks, iPhone

Saving iPhone applications inside data URLs

This is really basically the same theory as the iPhone bookmarklets Mat posted earlier (squeezing content into a URL), but it's a little less about function and a little more about storage. Currently, the iPhone doesn't allow you to save actual files locally, but it does allow you save URLs, so the idea here is to save entire applications (or other HTML content) in the form of a data URL.

It's a pretty wonky hack, but it works-- you can convert whole HTML pages, or even applications, depending on the URL length the iPhone's bookmarks allow, into data URLs (with the Perl script on that page if you don't want to do it manually), and then those data URLs can be loaded into MobileSafari on the iPhone, even in Airplane mode. The suggestion is made that this could allow persistent storage for web applications on the iPhone, but wouldn't that require allowing the HTML page to write to and read from the iPhone's bookmarks? Is that possible?

At any rate, maybe it's a good thing, for a little while at least, that Apple didn't release a "real" SDK for the iPhone. Web programmers are making their code do all kinds of flips and tricks to get every bit of access they can on the iPhone. People have been talking about browser-based, OS independent applications for years-- maybe Apple's insistence that iPhone developers go through the browser will bring about that world sooner than we thought.

[via DF]

Filed under: Software, Open Source, Developer

Platypus: create Mac applications from Ruby, Perl, shell scripts, etc.

MacResearch has posted a nice two part tutorial on using Platypus, a neat utility that allows you to "create native, flawlessly integrated Mac OS X applications from interpreted scripts." This include shell scripts, Perl, Ruby, Python, etc. With Platypus you can turn command-line only tools into full fledged, free-standing Mac applications that support drag and drop and even basic graphical feedback. Obviously this isn't going to make for a full GUI application, but it will allow you easily to create self-contained OS X applications that you can double-click to run. Especially for those in the science fields, and even for beginning (Ruby) script programmers like myself, Platypus makes it possible to get basic (and even not so basic) Mac app up and running very quickly.

Platypus is a free download from Sveinbjorn Thordarson, and donations are requested.

[Via MacResearch]

Update: fixed headline

Filed under: Software, Productivity, Internet Tools

PackRat 1.1 adds AppleScript and Automator support

Someone must have answered Rod Schmidt's call for AppleScripters, as he has just released PackRat 1.1, a major update to his offline Backpack syncing app that brings double-whammy support for both AppleScript and Automator. You can now get almost all your Backpack data via script, which means power users can do all sorts of extra-cool nerdy things now. A 'Synchronize with Backpack' Automator action is also included, offering easy access for the rest of us to set up auto-downloads in the morning or before we leave for a trip (hint: run the action as an app attached to an iCal event).

Check out Rod's announcement post for more details and to download a copy of the new PackRat version. As usual, PackRat will function as a non-expiring demo that allows working with 4 pages, while a license costs $24.95.

Filed under: Software, Video, iTunes

iTunes AppleScript to batch edit video metadata

iTunes 7 ushered in some great new video metadata, but editing this information, especially when in batches, can sometimes be a pain. For example: iTunes can differentiate between "movies" and "tv shows," (just check your Sources list on the left) but trying to select 14 episodes of an Aqua Teen Hunger Force season and pressing cmd-i doesn't yield any way to make a broad-sweeping change to "tv show."

If you're in the same boat as me (and I sure hope you are, or this is a useless post), a script from the venerable Doug (you know, AppleScripts for iTunes Doug?) called Set Video Kind of Selected can bring some automation to this process. In fact, as you can see, in allows you to edit not only the Video Kind, but the Show Name, Season Number and the starting episode number of the batch you've selected. This is a killer script for those of you who have some major iTunes video library cleanup work to do.

As usual, this script is provided free, but Doug solicits donations for all the rocking work he does with his now over 400-strong library of iTunes AppleScript.

Filed under: Audio, Software, Cool tools, Productivity, Tips and tricks, iTunes

iTunes song tagging redux

We reported a method for tagging iTunes tracks and creating on-the-fly playlists way back in January. However, it involved using Quicksilver and a couple of home-grown scripts, but we can dig it if some of y'all aren't down with a tool as broad-reaching as Quicksilver. Fortunately for the rest of you, a web designer and developer named Steven Campbell has written up a basic method for tagging iTunes tracks and creating playlists based on those tags. It more or less involves revealing the comments column in the song list for easy access, and using a simple system of comma-separated words to get your iTunes tagging on. This can work wonders for Smart Playlists, and Steven offers a few examples in his post.

For those still interested in the aforementioned Quicksilver scripts and tools, the author has issued a bit of an upgrade and a new script since we first reported them. First of all, the scripts now live at their own domain name, TuneTag.com. The scripts still allow you to tag the song you're listening to on the fly and create on-the-fly playlists from those tags, but the author also added a new script that lets you select any number of tracks in iTunes and tag them all in one fell swoop. As a Quicksilver fan I'm already in love with the power of these scripts, but either method should work well for bringing the web 2.0 tagging craze to iTunes.

Filed under: Software, Productivity, Internet Tools

An Adium Xtra for linking any browser's current page

I know Adium can insert links from some browsers by itself, but I just found a script at the Adium Xtras site which offers much more fine-grained control over inserting a link from any browser, with the page name's descriptive title linked nice and clean, instead of the long ugly URL you get from copy/pasting. As you can see, specific commands are included for all the major browsers (and even some not-so-major ones), as well as a catch-all Default Browser command. The ones I can test seem to work pretty well, though I'll admit I don't have any copies of iCab or Netscape lying around. Enjoy.

Filed under: iPod Family, Software, Productivity, Freeware

Mail to iPod AppleScript

Every now and then, I'll get an email with a lot of handy info that I'd like to have access to without having to take out my PowerBook. I usually save the message as a PDF and sync it with my phone, but this can be cumbersome and slow. Lucky for me, Ryo has created a handy AppleScript named MailPod just for these situations. When the script is first run, it creates a new mailbox within Mail.app named MailPod. Any emails you drag into the MailPod box will be synced to your iPod the next time you run the script.

If you're looking for a bit more features and control over your Mail to iPod syncing, check out MailToPod or iPDA.

[via Hawk Wings]

Filed under: iTS, Hacks

Windows app cracks iTMS v6 DRM

JHymn users might remember that iTunes 6 broke the DRM-stripping tool, and it seems that Apple's done a good job of keeping FairPlay locked down - until someone cooked up QTFairUse6 for Windows. Yes, it's a Windows app, but it can apparently strip purchases from iTMS version 6.0.4 and above of their constraining DRM. QTFairUse6 isn't pretty either - it's a python script that involves some tinkering, but this might be good news to those who believe that if you love something, you should set it free.

[via Engadget]

Filed under: Software, Productivity, Tips and tricks, Internet Tools

Safari AppleScript to enable Private Browsing, mount temporary download disk image

Now that we know how to enable the AppleScript menubar item, it's time to give Safari some AppleScript-enabled privacy features.

For all those times when you need to enable Private Browsing and 'private downloading' in Safari, a macosxhints reader has posted an AppleScript with setup instructions that can enable Private Browsing and mount a disk image and temporarily changing Safari's download folder to said disk image for the ultimate in browsing privacy (macosxhints uses 'online banking' as a usage scenario; I guess that works).

The script requires a little bit of setup and customization however, so check out the post for instructions. When you're finished you'll have a simple, handy AppleScript that prompts you to enable or disable Private Browsing in Safari, and then it will mount your encrypted (password-prompted) disk image for safe, secure and private downloading as well. Enjoy.

Filed under: Software, TUAW Tips

TUAW Tip: enable the AppleScript menu

As I was working on an AppleScript-related post this morning, I couldn't seem to find any TUAW Tips in our vast archives that explained how to enable that AppleScript menubar item (pictured) that is mentioned so often in Mac software circles. This, of course, called for just such a tip.

So: the AppleScript menubar item. It's a very handy tool for accessing all those AppleScripts you hear about that automate this or toggle that. As long as you save those scripts in ~/Library/Scripts (where ~ is your Home folder), they'll appear in this AppleScript menu - once you've enabled it. I personally think this menu item should be included in the default set of every Mac, but I'd wager that Apple sees this as a little too nerdy of a feature to drop on brand new users. Fair enough.

To enable this menu (nerd) in Tiger, go to /Applications/Applescript and open the AppleScript Utility. It offers a few options for handling AppleScripts, including turning on this menu and the order in which the menu displays scripts from both the default system level /Library/Scripts (in your main hard drive) and your personal ~/Library/Scripts folder. If you're on 10.3 (Panther), I *think* you have an /Applications/AppleScript folder, but instead of a full-blown AppleScript Utility app, it's an AppleScript called 'Install Menu' or something similar. Back on Tiger in the AppleScript Utility - you don't worry about the GUI Scripting option unless you come across a script that specifically needs it, though I don't think enabling this for simplicity's sake can harm anything either.

If this process went according to plan, you should now have your very own AppleScript menubar item like I have in the screenshot here. clicking it will offer a simple menu of all the scripts you have between the two directories you chose to display. As long as you enabled your personal Home script directory, any scripts you save there should appear in this menu immediately after saving, ready to carry out your bidding.

With that said, why not check out some of our past AppleScript posts, such as one of my personal favorites: an AppleScript from Fraser Speirs that opens iSync, syncs all your devices (such as a phone or PDA), then quits iSync. If you use an application launcher such as Quicksilver, you can tie handy scripts like these to Triggers (system-wide keyboard shortcuts) for even more convenience.

Tip of the Day

Use Spotlight as a reference tool. Type any word in the Spotlight box and one of the top entries will be a definition. Click on it, and it will bring up the dictionary application to check the word in either the dictionary, thesaurus, Apple database, or Wikipedia.


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

 

More Apple Analysis

AOL Radio TUAW on Stitcher