image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
Thread Tools
  #1  
Old November 25th, 2005, 10:37 AM
Amie's Avatar
Mac Convert for Life
 
Join Date: Jun 2005
Posts: 1,258
Thanks: 3
Thanked 0 Times in 0 Posts
Amie is on a distinguished road
Can Someone PLEASE Help Me with AppleScript?

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 have an iBook G4 with 1.25 GB RAM. I'm cool now.
Reply With Quote
  #2  
Old November 25th, 2005, 10:59 AM
bobw's Avatar
The Late: SuperMacMod
 
Join Date: Mar 2001
Location: Phila,PA
Posts: 8,835
Thanks: 0
Thanked 3 Times in 1 Post
bobw has a spectacular aura aboutbobw has a spectacular aura about
Applescripts can be used for more than just basic tasks like that. Check this site;

http://macscripter.net/

http://bbs.applescript.net/

You can also record scripts using the Applescript editor. Open that, click record, then perform some actions, and if it's scriptable, it will record a script for you.
__________________

Reply With Quote
  #3  
Old November 25th, 2005, 11:03 AM
Lt Major Burns's Avatar
"Dicky" Charlteston-Burns
 
Join Date: Jan 2005
Location: Manchester
Posts: 3,329
Thanks: 0
Thanked 1 Time in 1 Post
Lt Major Burns will become famous soon enough
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.
__________________
Dual 1.8GHz G5 2GB, 1TB, Radeon 9600XT 128MB, 10.5
20" Apple Cinema Display + Dell 2005FPW 20" dual-head
iBook G3 700MHz
640MB, 40GB, Rage128 16MB, 10.4, dying battery
Reply With Quote
  #4  
Old November 25th, 2005, 11:04 AM
Rhisiart's Avatar
Dal i Fynd! (Keep Going)
 
Join Date: Apr 2005
Location: West Britain
Posts: 1,645
Thanks: 14
Thanked 6 Times in 6 Posts
Rhisiart will become famous soon enough
Publishers often use Applescript for workflow automation.
__________________
Intel Mac Mini 1.83 1GB 10.5.4
PowerMac G4 833Hz 768MB 10.3.9

Education is when you read the fine print - experience is what you get when you don't.
Pete Seeger
Reply With Quote
  #5  
Old November 25th, 2005, 12:30 PM
MyMacBlog.com
 
Join Date: Apr 2005
Location: New Jersey, USA
Posts: 538
Thanks: 0
Thanked 0 Times in 0 Posts
dmetzcher is on a distinguished road
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.")
__________________
Dennis R. Metzcher
MyMacBlog.com: My experiences with the Mac OS, a switcher's point of view. With a new Mac tip each week day.
Reply With Quote
  #6  
Old November 25th, 2005, 12:59 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,464
Thanks: 3
Thanked 11 Times in 10 Posts
Mikuro is on a distinguished road
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.
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.2

I'm now a four-browser man. How on earth did this happen?!

Useful programs: PithHelmet, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
  #7  
Old November 25th, 2005, 01:38 PM
sourcehound's Avatar
Registered User
 
Join Date: Aug 2005
Posts: 210
Thanks: 0
Thanked 0 Times in 0 Posts
sourcehound is on a distinguished road
MacScripter is it

Quote:
Originally Posted by Amie
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
Reply With Quote
  #8  
Old November 26th, 2005, 08:35 AM
Amie's Avatar
Mac Convert for Life
 
Join Date: Jun 2005
Posts: 1,258
Thanks: 3
Thanked 0 Times in 0 Posts
Amie is on a distinguished road
Wow. Thanks for all the replies, guys! And thanks for the links. Gonna check 'em out...

Much appreciated.
__________________
I have an iBook G4 with 1.25 GB RAM. I'm cool now.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 08:20 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.