(Mis)adventures with AppleScript
Since I switched to the Mac, there’s one thing I’ve constantly avoided: AppleScript. While I’ve used programs that support it, and used scripts in the past, I’ve never found a reason to roll up my sleeves and dig into the code. Here are a couple of reasons for my aversion to AppleScript.
- Syntax is overly verbose – This is great in theory because you’d expect your code to read like natural language, and it’d be easier to understand. In practice, the code is hard to read, because it forces strict, programming-like syntax that breaks the flow of the language, and makes it seem awkward.
- It reminds me of VBScript – Like VBScript, AppleScript allows you to automate tasks in, and between applications. They even share similar syntax with “if … then … end if” blocks. Why is this bad? To put it quite simply, VBScript has made Microsoft Office a nightmare to work with, with embedded scripts that reference missing files, written by people who don’t know what they’re doing and shouldn’t be using a computer, let alone a scripting language. Thankfully this is less of a concern in Mac OS X, but my point still stands. VBScript gives me nightmares. Reminding me of it is probably not the best idea.
- Command-line is more powerful – Why would I want to learn a new scripting language, when Shell Scripting is much more powerful? Most of my experience with AppleScripts have been “Get input from user. Run shell script with input. Exit.”. Apple Script becomes just a friendly GUI wrapper for a command-line utility.
So despite all of this, I decided to adapt a command-line script into a little utility that can change the extension of a group of files. I may not like AppleScript, but it has proven to be pretty handy in this scenario.
Some Google searches got me most of the code, and after a little tweaking, I can present to you: Batch Change Extension.
Run it, and it will ask you for the files (multiple-select file open dialog), and the new extension. Simple enough. You can also use it like a droplet, and drag & drop the files you want to change onto it. In this case, it asks for extension only.
Download Here: Batch Change Extension