• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What's so great about AppleScript, anyway?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's so great about AppleScript, anyway?


  • Subject: Re: What's so great about AppleScript, anyway?
  • From: Doug McNutt <email@hidden>
  • Date: Sun, 14 Dec 2008 10:15:30 -0700

This dialog has a lot to say about AppleScript

Again, despite its weaknesses, I don't believe the possibly higher precision of other languages beats being able to write:

tell application "Finder" to move (every file whose name ends with ".txt") to folder "Text Files"

Well:
mv *.txt 'Text Files'
:-) but I do know what you mean.

Okay, but please forgive me for using this to illustrate a point: This is exactly my other point about clarity versus saving on typing. Shell commands were designed to save on typing, because they're usually entered interactively by the user every time they wish to run a command. That mv shell command looks like gibberish unless you know your way around a Unix shell. And it can take some time to memorize "mv" and how "*" works, and the order of the arguments. But the AppleScript version is probably at least vaguely comprehensible to someone who's never seen AppleScript before in their life. In fact, it's practically exactly how you'd explain in English what the shell command does.


It's probably all my fault for starting in 1960 when FORTRAN didn't have a year after it but:

Phil's shell command is at least easy to remember or to look up with a "man csh" command. Chris' tell line is easy to understand when you read it but it's nearly impossible to remember how to write it without an example in front of you. I personally find myself running to dictionaries or searching for sample code when I must do something in AppleScript. One thing for sure is that guessing NEVER works.

tell application Finder to move files that end in .txt to Text\ Files

tell application "Finder" to move all files whose names end in .txt to Text\ Files

please tell Finder.app to move every file that ends in ".txt" to directory "Text Files"

just move files of HFS type TEXT to /Users/myself/Documents/Text\ Files/, dammit.

Perhaps some artificial intelligence in the editor that would analyze guesses like those and suggest alternates? It would be easy to suggest sticking that curious word "file" (which translates to alias) in front of a path when some APPL requires it.

And, by the way, in the original tell above just what does "every file" mean. Surely it applies only to the current working directory. . . . . doesn't it? Just how does one tell Finder to:

cd $HOME/Documents    ?

And also, by the way, shouldn't it be Chris 2 and Chris 3? Don't forget Chris Nandor who was responsible for AppleScript from MacPerl.
--


Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: What's so great about AppleScript, anyway?
      • From: Philip Aker <email@hidden>
References: 
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: has <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Philip Aker <email@hidden>)
 >What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…) (From: Chris Page <email@hidden>)
 >Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…) (From: Philip Aker <email@hidden>)
 >Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…) (From: Chris Page <email@hidden>)

  • Prev by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by Date: Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…)
  • Previous by thread: Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…)
  • Next by thread: Re: What's so great about AppleScript, anyway?
  • Index(es):
    • Date
    • Thread