Let’s Talk About Scripts, Baby

Automator, touted as one of the big features of Mac OS X 10.4. Have you used it? Of course not, it’s rubbish.

For one, the program itself is horribly resource intensive. You need a 4-way G5 with 4GB of memory for it to be useable. I don’t know what it’s doing, but the longer you leave it open, the slower and slower the program gets.

Secondly, there’s no good way to debug. Stuff happens, and you just hope it’s the right stuff. And it doesn’t help testing when Automator slows to a crawl.

Automator, what a rubbish program. But then it finally works, and the clouds part and the sun shines down and all is well with the world.

Yes, I’ve finally gotten some results with Automator. I’ve created two workflows. The first creates a thumbnail and uploads the thumbnail and original image to raishad.com. The second is a “Folder Action”. A “Folder Action” is a script that is attached to a folder, and it runs whenever you drop a file in that folder. The second workflow uploads .torrent files that I drop in that folder, to a folder on my server that Azureus scans for new torrents.

After the jump, I’ll walk through the Workflows

Workflow 1 Image Upload If you notice, I don’t really do much with Automator with this workflow. My first try with Automator months ago was trying to create a similar workflow. I wanted to grab a comic, scale it and set it as my desktop. But image manipulation with Automator isn’t that great. So I wrote the heart of the workflow in Ruby, fileuploader.rb. It’s pretty simple. It uses RMagick for the image processing.

Workflow 2 Torrent This one was tricky. There’s an action called “Get Selected Finder Items” that I was trying to use. In the context of a “Folder Action”, it includes the folder as well as the files in that folder in the “Selected Finder Items” heading. So I was uploading the whole folder each time. Not what I wanted. So you see how you have to shift your thinking a bit. I first had to get the folder, and then it’s contents. I also made use of an “Upload to FTP” action I found on Apple’s Download Site.

Update: And it seems I’ve found a bug while uploading the images for this post. For some reason, if you select a bunch of images, it only uploads the first one, eventhough all the files are passed to the “Run Shell Script” action. And that is why working with Automator is a test in patience.

Update, Again: I fixed the first workflow, Workflow 1 Image Upload Fixed Seems it wasn’t Automator’s fault. It was Bash’s fault. I probably should’ve looked up what exec did before using it.

exec
This shell builtin replaces the current process with a specified command. Normally, when the shell encounters a command, it forks off [3] a child process to actually execute the command. Using the exec builtin, the shell does not fork, and the command exec’ed replaces the shell. When used in a script, therefore, it forces an exit from the script when the exec’ed command terminates. For this reason, if an exec appears in a script, it would probably be the final command.

This entry was posted in Apple, Software. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Long
    Posted October 26, 2005 at 12:12 pm | Permalink

    Why don’t you just hire an offshore personal assistant like everyone else?

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">