Saving to desktop with TextEdit - El Capitan vs Sierra [2]
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