• 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: Novice applescript question about saving all open files..
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Novice applescript question about saving all open files..


  • Subject: Re: Novice applescript question about saving all open files..
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 30 Sep 2001 09:52:28 -0700

On 9/30/01 8:59 AM, "Charles Bennett" <email@hidden> wrote:

> Hi, I've been reading the "finder" book and am trying to figure
> out how to tell all of the open applications to save any open files and quit
> in preperation for a shutdown.
>
> This is under OS X 10.1
>
> I tried
>
> tell application "Finder"
> if the (count of applications) is not 0 then
> tell every application to quit saving = yes
> end if
> end tell
>
> This passes the syntax check and run with no error (or messages for that
> matter)
> but doesn't see to cause my test app (TextEdit with an open file that has been
> saved once
> but now has modified text)


A few pointers:

1) The "Finder book" was written for OS 8.5. Huge swaths of it, maybe most
of it, will not apply in OS 10.1

2) Passing the Syntax check does not mean that it will do what you want it
to do. Normally it means that you have not used incorrect constructions (but
you have here).

tell every application to quit saving = yes

will not save anything, since that is incorrect syntax. The Finder has
traditionally (and may still in OS 10.1) had coercions to "smooth over" poor
syntax instead of erroring. What you are probably trying to do is

tell every application to quit saving yes

which will not work as you want (see below). I imagine that the Finder is
coercing your command to :

tell every application to quit

and simply ignoring the faulty ' = ' . Or maybe it's coercing the 'yes' into
'true' and coercing the whole line into a banal boolean statement about
something or other. The fact that nothing errors is a bug, IMO.


3) The only 'application' in the Finder's dictionary is itself, and using
the event 'quit' in a Finder block tells the Finder itself to quit. But it
didn't.


4.) I think what you want is this. You want to ignore background
applications (don't try to quit them!), but otherwise to get the running
applications. A running application is actually the Finder term 'process',
which is working again in 10.1, as is its parameter 'visible'. Then ,
_outside_ the Finder block , tell each such application, except the Finder,
to quit. The 'saving yes' part won't work if the application does not have
this parameter implemented by its developers and/or if there is a documented
which has never been saved, since it has to ask you where to save it to, and
what to name it. You'll have to experiment with that part and see if maybe
you should just cut it out entirely. But this is the general idea
(UNTESTED).


tell application "Finder"
set theApps to name of every process whose visible is true
end tell

repeat with i from 1 to (count theApps)
set theAppName to item i of theApps
if theAppName is not "Finder" then
tell application theAppName to quit -- saving yes -- try it
end if
end repeat


--
Paul Berkowitz


References: 
 >Novice applescript question about saving all open files.. (From: Charles Bennett <email@hidden>)

  • Prev by Date: Parsing XML in OS 10.1
  • Next by Date: Re: Parsing XML in OS 10.1
  • Previous by thread: Novice applescript question about saving all open files..
  • Next by thread: Parsing XML in OS 10.1
  • Index(es):
    • Date
    • Thread