• 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: save and close window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: save and close window


  • Subject: Re: save and close window
  • From: Christopher Stone <email@hidden>
  • Date: Thu, 24 Jul 2014 23:56:41 -0500

On Jul 24, 2014, at 14:43, okn <email@hidden> wrote:
In a Keyboard Maestro macro, I have a TextWrangler open document, into which some text has been appended, and now: how to write the Applescript just for saving this active file (which is document 1) and then closing the window (of document 1)?
______________________________________________________________________

Hey Omar,

Here are a few examples.

-------------------------------------------------------------------------------------------
set savePath to path to desktop as text
set docName to "My Test Document"
set _text to "Now is the time for all good men to come to the aid of their country."

tell application "BBEdit"
  activate
  set newDoc to make new document with properties {name:docName, text:_text}
  save newDoc to (savePath & docName)
end tell

# OR

tell application "BBEdit"
  activate
  set newDoc to make new document with properties {text:_text}
  save front text document to (savePath & docName)
end tell

# If the document is has previously been saved to disk:
tell application "BBEdit"
  activate
  tell front document
    save
    close
  end tell
end tell
-------------------------------------------------------------------------------------------

This may seem very simple, but ...

It is simple, but simple is not always easy.  :)

The more AppleScript you write the easier it gets, but it's still not always easy.

--
Best Regards,
Chris

 _______________________________________________
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

References: 
 >save and close window (From: okn <email@hidden>)

  • Prev by Date: Screwy Choose file action
  • Next by Date: random walk AS — blocking out the moves
  • Previous by thread: save and close window
  • Next by thread: Screwy Choose file action
  • Index(es):
    • Date
    • Thread