Re: How to create a document?
Re: How to create a document?
- Subject: Re: How to create a document?
- From: Shane Stanley <email@hidden>
- Date: Mon, 18 Jul 2016 22:50:17 +1000
On 18 Jul 2016, at 10:39 PM, Mitchell L Model <email@hidden> wrote:
In a rare out-of-the box thought I realized that we were all too fixated on AppleScript, unsurprisingly given that this is the AppleScript list. The following script performs flawlessly and works whether the file exists or not:
to createNewDocument(theApplication, thePath) do shell script "touch " & quoted form of the POSIX path of thePath tell application theApplication to open thePath end createNewDocument
Yes and no. You shouldn't generally pass a path to an application -- it's going to fail with any sandboxed app. Pass a file object of some sort.
And if you want to create a file then open it, there's no need to go to the overhead of launching a shell:
set fileName to "This is a test.txt" set theFile to ((path to desktop as text) & fileName) as «class furl» try set fileRef to open for access theFile with write permission close access fileRef end try tell application "TextEdit" to open theFile
|
_______________________________________________
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