Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript: Cannot save changes after edit a file in TextEdit

Hello,

I need next task: open existing file, type some text in this document, save and close.

I written next script:


set theText to "I want to paste this text into existing document"

set theFile to (path to desktop as string) & "autotest:word.rtf"


tell application "TextEdit"

activate

opentheFile

makenewparagraphat end of front documentwith datatheText

closetheFilesavingyes

end tell



Looks like it works. But when I reopen this document manualy - there are no changes.


Please tell me what i do wrong,

Thanks!

Mac mini, OS X Mavericks (10.9)

Posted on Dec 2, 2013 5:12 AM

Reply
Question marked as Best reply

Posted on Dec 2, 2013 6:52 AM

Change

closetheFilesavingyes

to

save front document

close front document



set theText to "I want to paste this text into existing document"

set theFile to (path to desktop as string) & "autotest:word.rtf"


tell application "TextEdit"


activate


opentheFile


makenewparagraphat end of front documentwith datatheText


save front document


close front document

end tell



Note: TextEdit will still be active, so add quit if you want TextEdit Closed

2 replies
Question marked as Best reply

Dec 2, 2013 6:52 AM in response to Mikhail Tanaev

Change

closetheFilesavingyes

to

save front document

close front document



set theText to "I want to paste this text into existing document"

set theFile to (path to desktop as string) & "autotest:word.rtf"


tell application "TextEdit"


activate


opentheFile


makenewparagraphat end of front documentwith datatheText


save front document


close front document

end tell



Note: TextEdit will still be active, so add quit if you want TextEdit Closed

Apr 8, 2014 12:01 PM in response to Tony T1

I am looking to have the command

tell application "Finder" to set theFiles to files of theFolder as alias list

repeat with eachFile in theFiles

tell application "TextEdit"


activate


makenewdocumentat the front

set TiffInfo to do shell script "/usr/bin/exiftool -EXIF -Artist " & quoted form of POSIX path of eachFile

set the text of the front document to TiffInfo

end tell

end repeat


To save the out put of

set TiffInfo to do shell script "/usr/bin/exiftool -EXIF -Artist " & quoted form of POSIX path of eachFile

into one file and send it to a separate file for each time the command runs?

How can I change the command

Applescript: Cannot save changes after edit a file in TextEdit

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.