Open for Business, Yes Sir

You’d be forgiven, of course, for thinking that this blog’s maintainer had just been deported to Russia for spying – such is the rate of updates. This, sadly, is not the case. The real reason is far more prosaic: I have been distracted.

However, the Internet toils tirelessly whether I’m paying attention or not. One tireless toiler is Mike Hall, a guy who has more rb-appscript prowess in his little finger than I have in my entire hand. He kindly pointed me in the direction of his blog, which has a terrific array of ruby scripts. It’s so good that I’m going to put it on its own line:

http://mph.puddingbowl.org/category/ruby/

If you’re jonesing for more app("Grue").do_some_stuff({:like => "now"}) then I highly recommend you check it out. I plan on porting Mike’s scripts over here too, so that they’re preserved for posterity, but mainly so I look like I know what I’m doing.

Posted in learning | Leave a comment

Finder: Symlink This Window to That One

Symlinks! They’re not just for Christmas. They are, in fact, just like aliases, enabling you to litter your hard drive with shortcuts in no time flat. You can make them in the terminal with the “ln -s” command, but if you’ve got the windows open in the Finder, hell! Why not use ‘em?

This little baby uses the front two Finder windows to figure out the source and destination. Just be careful that they are the front two windows, or you may get unexpected – perhaps terrifying – results. I took the time to build in a confirmation dialog; just edit the code if you feel like living dangerously.

The source code dances a merry jig, over yonder.

Download Symlink-this-window-to-that-one.rb.zip.

Read More »

Posted in finder | Leave a comment

Photoshop: Export Layer Comps

photoshop.pngWeb designers, in particular, are famous for making Photoshop files with 134 layers, all named “Layer 2 copy copy copy copy”, and spending an hour turning them on and off to show you one iteration of their handiwork. Using Photoshop and not using layer comps is akin to chartering a Gulfstream jet – and then taxiing to your destination.

This script will save all your layer comps separately, in a format of your choosing. “But,” I hear you cry, “Photoshop already comes with a script that already does that already”. Yes, but this one uses the magnificent “Save for Web” command, which performs superior squishing and optimising.

Download Export-layer-comps.rb.zip.

The source code is rubbing its sleepy eyes and yawning, just over there.

Read More »

Posted in photoshop | Leave a comment

InDesign: Update All Modified Images

indesignThis has actually been added as a command in the latest release of InDesign (curse you Adobe, for improving your software and rendering my scripts obsolete). It still serves as a useful example for how to filter a bunch of objects based on a selector.

Download Update-all-modified-images.rb.zip.

As it’s only little, I’ve decided to let this source code live on the front page.

#!/usr/bin/env ruby

# rb-appscript code by Ian Haigh : http://ianhaigh.com/
# Fri Dec  4 15:54:38 EST 2009

require 'rubygems'
require 'appscript'
include Appscript

ai = Appscript.app('Adobe InDesign CS4.app')

#  Update all modified images
ai.active_document.links[its.status.eq(:link_out_of_date)].update
Posted in indesign | 1 Comment

iTunes: Total Size of Current Playlist

itunesThis script, erm, duplicates the functionality of simply looking at the bottom of the iTunes window, where you’ll find the total size of the current playlist smugly peering up at you. So why did I write this? Your guess is as good as mine. However, in the name of providing examples for would-be iTunes scripters, I present it here in all its redundant glory.

Download Total-size-of-current-playlist.rb.zip.

The source code is cowering sheepishly around the corner.

Read More »

Posted in itunes | Leave a comment

Illustrator: All Layers Visible

illustratorThe clue is in the title. This is especially handy when you attach a keyboard shortcut with a utility such as – the frankly indispensableFastScripts.

Download All-layers-visible.rb.zip.

The source code is sheltering from a brief sun shower below.
Read More »

Posted in illustrator | 2 Comments

InDesign: Reveal Links in Finder

indesignLoops through all the selected items, attempts to figure out whether any of them are linked images, and opens their containing folders, selecting all of ‘em.

Download Reveal-links-in-Finder.rb.zip.

The source code is bouncing from foot to foot in anticipatory glee, just after the jump.
Read More »

Posted in indesign | Leave a comment

Keynote: Add a Folder of PNGs to This Slide

keynoteWhat, you might ask yourself, is the point of this script? Can’t I just drag images into Keynote? Well, replies this hastily anthropomorphised bunch of code, you could do that. But your images will be strewn hither and thither, rather than nicely centered on your slide. Quod erat, as my uncle would say, demonstrandum.

Download Add-a-folder-of-PNGs-to-this-slide.rb.zip.

The source code is sleeping gently, just down there. Hush now, source code.

Read More »

Posted in keynote | Leave a comment

iTunes: Remember Position of Selected

itunesHave you ever downloaded something that wasn’t a podcast, but should behave like a podcast? You know, Russell Crowe reading the collected works of Tolstoy, that kind of thing.

This simple script takes your iTunes selection and sets the “bookmarkable” property to true, so it will remember where you’re up to (invaluable during War and Peace). It will also removed the “shufflable” flag, so that In Our Time from BBC Radio 4 won’t start playing at your next house party. Finally, it will set the genre to “podcast”, for no reason other than it seems more suitable than “grindcore”.

Download Remember-position-of-selected.rb.zip

The source is available for your delectation.

Read More »

Posted in itunes | Leave a comment

Illustrator: Turn Off Artboard Junk

illustratorIllustrator CS4 has artboards. All well and good. However, the amount of information that these things are festooned with defies belief – it’s like being in the cockpit of a Stealth Bomber. OK I’m exaggerating (slightly) but this script kills the cross hairs, safe areas, and center markers on all your artboards, in one fell swoop.

Here’s a demonstration. Double click for full screen – if you dare.

Download Turn-off-artboard-junk.rb.zip

Source code follows.

Read More »

Posted in illustrator | Leave a comment
  • What’s this all about then?

    rb-appscript is a powerful way to automate your Mac. It's similar to Applescript but it's built in Ruby, which means you get to leverage that language's powerful syntax and libraries. Giving you more time to make toasted sandwiches. You want long-winded explanations? We got those.

    Please note that these scripts are by no means bulletproof, and are intended to provide examples of application scripting. I take no resposibility for any loss of data or mishaps; you download and run everything at your own risk. That said, I use all of these scripts in a production environment every day (well – more accurately, I use some of these scripts in a production environment most days).