Can Someone PLEASE Help Me with AppleScript?

Amie

Mac Convert for Life
OK, I was doing some reading and going through tutorials in order to learn AppleScript (I bought my first Mac about six months ago--lovin' it!--and I'm going for my Geek Badge). ;) Seriously though, as I was about halfway through the first tutorial, I asked myself, "What in the HECK is the point of AppleScript?" Wouldn't it be easier to just CLICK on the darn window/menu bar/command in order to accomplish the task? For example, the tutorial gives a simple example of an AppleScript: tell application "Finder" to open the startup disk. And then: tell application "Finder" to close window "Macintosh HD". Now, wouldn't it be a heck of a lot easier--and faster!--to just CLICK on the HD to open the window, and then click on the X to close it--instead of typing all that MESS?!?!?

Someone PLEASE explain this to me ... 'cause I have a feeling I'm missing something. LOL
 
the idea is that you string up a succession of commands like close window etc. to make a script that runsa tedious task on it's own. the script i use the most is for itunes, all it does is force quit the application itunes after 60 minutes (it's actually a huge number in seconds, but the theory works), a sleep timer.
 
AppleScript's also not bad if you want to use Xcode (once you've learned a little AppleScript) to create a standalone application (Google: "AppleScript Studio). Check out something like Carbon Copy Cloner for an example of an app written in AppleScript Studio. Mostly, though, AppleScript is designed for workflow automation, and can be really helpful when you have several steps in a process flow. (i.e. - "copy pictures from a folder into another folder, apply these settings to them, crop them, upload them to my FTP server.")
 
The tutorials just give you simple examples to get you familiar with the syntax and stuff. Yes, using an AppleScript for such a simple task would be a little silly. The usefulness of AppleScript comes from its ability to string together these simple tasks to do very complicated things.

Here are a few examples of things I do with AppleScript:

1. File sorting. I have a script attached to my web downloads folder that automatically sorts incoming files into sub-folders based on their type. It also changes the modification date of each incoming file so that I can sort them by the date I downloaded them rather than the date the file's author last edited it. Moving files is a simple task, but it's much faster to have a script do it for me automatically, in the background. And altering modification dates is something you can't easily do "manually".

2. Process my iTunes tracks. iTunes has a robust scripting library, and you can do all sorts of neat things with it. For example, I have a script to do a simple find-and-replace in the title or album of all selected tracks. There's no quick way to do this without AppleScript. I also have some scripts to rename files based on their title/artist/etc. tags (iTunes can do this automatically, but not in a way I like).

3. Quick & easy backups. I have a script in my Dock that when launched will automatically create a complete working backup of the project I'm currently working on in Xcode. It automatically puts it in the appropriate folder, automatically names it based on the current time, and asks me if I want to attach a comment to it. This makes my life so much easier.

4. Batch renaming files. Apple includes some very useful renaming scripts with OS X. They're located in "/Library/Scripts/Finder Scripts" (that's the root Library, not the one in your Home folder). They're a little scary, but don't be discouraged; you can make useful and effective scripts that are much shorter and simpler than that. Apple's are so complicated because they're made to be more flexible than most scripts you'd make for your own personal use. Most of my scripts, even ones that do much more complicated things than renaming files, are nowhere near so long and confusing-looking as Apple's.

Those are just a few examples. AppleScript is an incredibly useful and powerful tool. It's well worth learning.
 
Amie said:
OK, I was doing some reading and going through tutorials in order to learn AppleScript (I bought my first Mac about six months ago--lovin' it!--and I'm going for my Geek Badge). ;) Seriously though, as I was about halfway through the first tutorial, I asked myself, "What in the HECK is the point of AppleScript?" Wouldn't it be easier to just CLICK on the darn window/menu bar/command in order to accomplish the task? For example, the tutorial gives a simple example of an AppleScript: tell application "Finder" to open the startup disk. And then: tell application "Finder" to close window "Macintosh HD". Now, wouldn't it be a heck of a lot easier--and faster!--to just CLICK on the HD to open the window, and then click on the X to close it--instead of typing all that MESS?!?!?

Someone PLEASE explain this to me ... 'cause I have a feeling I'm missing something. LOL

I agree with Bob, MacScripter is the best place to go for help learning AppleScript.

Sourcehound, author of Mac HelpMate (made with AppleScript)

http://www.macworkshops.com/machelpmate
 
Wow. Thanks for all the replies, guys! And thanks for the links. Gonna check 'em out...

Much appreciated. :)
 
sourcehound said:
I agree with Bob, MacScripter is the best place to go for help learning AppleScript.

Sourcehound, author of Mac HelpMate (made with AppleScript)

http://www.macworkshops.com/machelpmate
OK, I went to this site and it's for something called Help Mate? And it says that it's for Tiger (I'm running Panther). And there are no AppleScript workshops listed that I saw. Did you maybe post the wrong link?...
 
There's also a great book titled 'AppleScript: The Missing Manual". It's well written and will definitely get you on your way with a series of walkthrough projects. Check it out. It's by Adam Goldstein. The writing style is easy to follow and makes learning a bit more fun than most tutorials I've found.
 
Back
Top