Saturday, May 03, 2008

Note from Bill about scripting

"We're an all Mac house. The Mac comes with Perl, PHP, Python, Ruby, AppleScript, and shell scripting all built in. AppleScript is an Object Oriented scripting language that allows you to make applications work together that normally aren't designed to cooperate. Most applications on the Mac are scriptable and it allows for a lot of custom automation. In the case of images, you can manipulate them in any way you wish in one of several applications. Even Photoshop on the Mac is completely scriptable. Many applications allow you to do things with scripts that you can't even do through the user interface. So it's got a lot of power, if you know how to do it. And since AppleScript can call and use all of the other scripting languages on the Mac, it's possible to automate almost anything you can imagine.

The script Bill wrote for me is an AppleScript that uses the Mac's Finder to duplicate and rename the file, and then it uses a photo editor called GraphicConverter to shrink and rotate the photo. I just have to drag and drop one or more photos and drop them on the script icon. The computer just prompts me for the name of the photo I'm looking at and I type that in and press enter. It prompts me to rename each photo. I provide the names, it does all the rest.

6 comments:

B said...

*waves*

Very interested MacGirl here!

:D

DaviMack said...

Completely PC world here. Our process is much more labour intensive, but only insofar as I actually take three pictures at a time rather than one & need to weed through them to decide which one to keep (I set the camera to 'auto-exposure bracket' by as much as one full stop - take a look at your camera & you might find yours can do the same thing & you may like the results).

As to the scripting on my end, it's mostly just to bulk rename the files (I use a spreadsheet formula to generate rename statements which then get dropped into a .bat file). Maybe not as easy as your process ... but I'm the one writing the scripts. ;)

But do tell Bill: that's not Mac, that's UNIX! :)

mira's papa said...

@ Davimack

Hmm, seems like you haven't been paying attention for the last 8 years. When Apple moved to OS X in 2000, it was effectively moving onto a transformed version of the OpenStep OS that ran originally on the NeXT computers developed in the mid 80s.

OpenStep is/was built on UNIX, and OS X is as well. The underpinnings of OS X are FreeBSD, and OS X is a branch off of the UNIX family tree (which is a long and complex tree).

So while I have all of the regular Mac applications, I can pop open a terminal window and I've got all of that crunchy UNIX goodness available. Something on the order of 1133 command line applications and tools at current count.

But just to clarify one thing, AppleScript was not something that originated in UNIX. It was the scripting system that was used on the old Classic Mac OS. It's an event driven Object Oriented system that provides a message passing and object passing system to applications and the OS. Developers who choose to take advantage of it can expose this in their applications so they can then be run by scripts. And this scripting system was brought to OS X when Apple developed X. So we now have AppleScript and all of the other traditional UNIX scripting languages as well.

The consequence of this is that now if I want to scale one of Jackie's photos, I've got choices. Use AppleScript and any scriptable photo editor (of which there are choices), or use a UNIX tool.

For quick and easy, AppleScript typically is the tool of choice. For fast, robust, industrial strength batch processing work I use a mixture of tools, depending on the nature of the task(s) and how much speed matters. But frequently this involves shell scripting.

Apple also provides a free set of superb developer tools with a complete IDE. Or if command line is your thing, you can write your C, C++, java, objc, obj-c++, and fortran and feed it from plain text files.

So yeah, it's a Mac, but it's UNIX too. Anything that runs on BSD or Linux you can likely compile to run on OS X. The fink project even provides compiled binaries for the faint of heart. But it's all there.

B said...

*faints at all the lovely geeky talk*

*swoon*

:D

B

I am Curious Llama. said...

I want one of these new fangled ultra light airmac laptops. DROOL!!!! However, I know a woman who has had to have her's replaced three times. She says it is very fragile. So, I guess we should wait until Mac sorts out the bugs. In the meantime, we can all fantasise.

DaviMack said...

It's not just the Mac ones that have the trouble, it goes across the board. The thinner the laptop, the more likely it is to suffer when you pick it up, particularly if you pick it up by the corner (as so many do). This torques the machine, causing things to stress inside & eventually fail.

So, small is fine, but small is fragile.