• 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: Problem saving a new file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem saving a new file


  • Subject: Re: Problem saving a new file
  • From: Miguel Torikachvili <email@hidden>
  • Date: Sat, 20 Oct 2012 00:37:21 -0300

You can use this to set manually the file`s path, name and content every time the script runs:

set pathToDocuments to (path to documents folder)
set pathToFolder to (choose folder default location (pathToDocuments))
set nameFile to text returned of (display dialog "Set new file name:" default answer "New Notes.rtf")
set newFile to (pathToDocuments & nameFile as string)

tell application "TextEdit"
activate
make new document with properties {path:newFile}
set text of document 1 to text returned of (display dialog "New file content:" default answer "Simple test")
save document 1 in newFile
quit
end tell


Best regards,

Miguel Torikachvili

Em 19/10/2012, às 16:00, email@hidden escreveu:

Send AppleScript-Users mailing list submissions to
email@hidden

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.apple.com/mailman/listinfo/applescript-users
or, via email, send a message with subject or body 'help' to
email@hidden

You can reach the person managing the list at
email@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of AppleScript-Users digest..."


Today's Topics:

  1. Re: What's in a word (Shane Stanley)
  2. Problem saving a new file (Eric Robertson)
  3. Re: Problem saving a new file (koenig.yvan)


----------------------------------------------------------------------

Message: 1
Date: Fri, 19 Oct 2012 09:22:59 +1100
From: Shane Stanley <email@hidden>
To: AppleScript-Users <email@hidden>
Subject: Re: What's in a word
Message-ID: <email@hidden>
Content-Type: text/plain; charset=iso-8859-1

On 19/10/2012, at 3:33 AM, Paul Berkowitz <email@hidden> wrote:

Back in olde-worlde 10.5.8, those same International System Preferences
popup options exist, but the "Standard" setting for someone using English
language in the US behaves instead the same way as ³English (United States,
Computer)² and as John had expected. Evidently a bug in 10.5 that was later
fixed.

A new API for this was introduced in 10.5, and the former method was deprecated in 10.6. AS probably only changed with the deprecation, and perhaps the UI setting only affected the new API. Just a theory...


--
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>




------------------------------

Message: 2
Date: Fri, 19 Oct 2012 14:54:27 +0100
From: Eric Robertson <email@hidden>
To: email@hidden
Subject: Problem saving a new file
Message-ID: <email@hidden>
Content-Type: text/plain; charset="utf-8"

I'm a newbie and I'm having problems saving some data away to a new file. I've tried various things but the nearest I've got to doing this was the following:

tell application "TextEdit"
set newFile to "/Users/ericrobertson/Documents/New Notes.rtf"
activate
make new document with properties {path:newFile}
set text of document "New Notes.rtf" to "This is sample text"
save document "New Notes.rtf"
end tell

However although the document appears OK inTextEdit with the text included in it I get the message that I don't own the document "New Notes.rtf" and don't have permission to write to it. Do I have to set the file permissions in some way? I did try setting the name property as well as the path but this made no difference as it seemed to derive the name from just the path.

Incidentally i did find that if I just set the name property the path was set to /Users/ericrobertson/Library/Containers/com.apple.TextEdit/Data/Users/ericrobertson/Documents/New Notes.rtf.

I'm still on Lion (10.7.5) using TextEdit v1.7.1.

Eric Robertson


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20121019/b848378b/attachment.html>

------------------------------

Message: 3
Date: Fri, 19 Oct 2012 18:09:34 +0200
From: "koenig.yvan" <email@hidden>
To: liste AppleScript US <email@hidden>
Subject: Re: Problem saving a new file
Message-ID: <email@hidden>
Content-Type: text/plain; charset="iso-8859-1"


Le 19/10/2012 à 15:54, Eric Robertson <email@hidden> a écrit :

I'm a newbie and I'm having problems saving some data away to a new file. I've tried various things but the nearest I've got to doing this was the following:

tell application "TextEdit"
set newFile to "/Users/ericrobertson/Documents/New Notes.rtf"
activate
make new document with properties {path:newFile}
set text of document "New Notes.rtf" to "This is sample text"
save document "New Notes.rtf"
end tell

However although the document appears OK inTextEdit with the text included in it I get the message that I don't own the document "New Notes.rtf" and don't have permission to write to it. Do I have to set the file permissions in some way? I did try setting the name property as well as the path but this made no difference as it seemed to derive the name from just the path.

Incidentally i did find that if I just set the name property the path was set to /Users/ericrobertson/Library/Containers/com.apple.TextEdit/Data/Users/ericrobertson/Documents/New Notes.rtf.

I'm still on Lion (10.7.5) using TextEdit v1.7.1.

Eric Robertson


You may use :

set p2doc to path to documents folder as text
set newName to "New Note.rtf"
tell application "System Events"
make new file at end of folder p2doc with properties {name:newName}
end tell
set newFile to (p2doc & newName) as alias
tell application "TextEdit"
activate
make new document with properties {name:newName}
set text of document 1 to "This is sample text"
save document 1 in newFile
end tell

tested with TextEdit  1.8 (301) under 10.8.2

Yvan KOENIG (VALLAURIS, France) vendredi 19 octobre 2012 18:09:26



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20121019/52cbacb7/attachment.html>

------------------------------

_______________________________________________
AppleScript-Users mailing list
email@hidden
https://lists.apple.com/mailman/listinfo/applescript-users

End of AppleScript-Users Digest, Vol 9, Issue 412
*************************************************

 _______________________________________________
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

  • Prev by Date: Re: Problem saving a new file
  • Next by Date: Re: Problem saving a new file
  • Previous by thread: Re: Problem saving a new file
  • Next by thread: Re: Problem saving a new file
  • Index(es):
    • Date
    • Thread