• 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
Saving to desktop with TextEdit - El Capitan vs Sierra [2]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saving to desktop with TextEdit - El Capitan vs Sierra [2]


  • Subject: Saving to desktop with TextEdit - El Capitan vs Sierra [2]
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 24 Dec 2016 16:54:59 +0100

As a follow-up to my previous post, a script suggesting various ways to save a document to the desktop. I guess TextEdit may be viewed as a prototype application for such matters, so that the behaviors described/the questions raised hereafter are probably broader.

	-- Let’s be sure to start with something to save.
	tell application "TextEdit"
		make new document
	end tell

	-- Saving to a POSIX file.
	set newFile to POSIX file (POSIX path of (path to desktop) & "test1.rtfd")
	tell application "TextEdit"
		tell document 1
			save in newFile
		end tell
	end tell

	-- Saving to a POSIX file ('path to desktop' returns in this case the same as above).
	-- Note that the "my" keyword is needed.
	tell application "TextEdit"
		tell document 1
			set newFile to my POSIX file (POSIX path of (path to desktop) & "test2.rtfd")
			save in newFile
		end tell
	end tell

	-- Saving to an alias built on the fly, the file being non existent.
	-- Note the "alias … of document 1" in Script Editor's log.
	-- Would have expected a failure here, but no…
	set newFile to ((path to desktop as text) & "test3.rtfd")
	tell application "TextEdit"
		tell document 1
			save in alias newFile
		end tell
	end tell

	-- "Saving to a string" - a posix path.
	-- Fails under El Capitan (as expected, would I be tempted to say)
	set newFile to (POSIX path of (path to desktop) & "test4.rtfd")
	tell application "TextEdit"
		tell document 1
			save in newFile
		end tell
	end tell

	-- "Saving to a string" - an HFS path.
	-- Fails under El Capitan (as expected, would I be tempted to say)
	set newFile to ((path to desktop as text) & "test5.rtfd")
	tell application "TextEdit"
		tell document 1
			save in newFile
		end tell
	end tell

	tell application "TextEdit"
		quit
	end tell

Axel


 _______________________________________________
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: Saving to desktop with TextEdit - El Capitan vs Sierra [2]
      • From: Mitchell L Model <email@hidden>
    • Re: Saving to desktop with TextEdit - El Capitan vs Sierra [2]
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Saving to desktop with TextEdit - El Capitan vs Sierra [1]
  • Next by Date: Re: Saving to desktop with TextEdit - El Capitan vs Sierra [2]
  • Previous by thread: Re: Saving to desktop with TextEdit - El Capitan vs Sierra [1]
  • Next by thread: Re: Saving to desktop with TextEdit - El Capitan vs Sierra [2]
  • Index(es):
    • Date
    • Thread