Tuesday, November 19, 2019

#1 2019-11-07 01:46:32 pm

davec0864
Member
Registered: 2018-11-06
Posts: 18

Save an Open Textedit Document

I have a script that opens a text file from a URL in TextEdit.  I need to save the open text file to a specific location.  Here's what I have tried but the file isn't saved anywhere and I get no error message.  Not sure what I'm doing wrong.

property TxtFilePath : "/Applications/Clients/TxtFileName.txt"

set ThisTxtFile to TxtFilePath as POSIX file as alias

tell application "Safari" to activate
tell application "System Events"
    tell application "Safari"
        open location "http://website.com/TxtFileName.txt"
    end tell
    tell application "TextEdit"
        save as ThisTxtFile
        quit
    end tell
    tell application "Safari"
        close current tab of front window without saving
    end tell
   
end tell

Offline

 

#2 2019-11-07 11:23:03 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 712

Re: Save an Open Textedit Document

Hi, davec0864.
I can't test as I don't have access to your website text file. Here, you tell to TextEdit to save, but save what? In what coding? Where?
So, try this:

Applescript:


property TxtFilePath : "/Applications/Clients/TxtFileName.txt"

tell application "Safari" to open location "http://website.com/TxtFileName.txt"

set ThisTxtFile to TxtFilePath as POSIX file as alias
tell application "TextEdit"
   save document 1 as Unicode text in ThisTxtFile
   quit
end tell

tell application "Safari" to close current tab of front window without saving

Last edited by KniazidisR (2019-11-07 11:31:28 pm)


Model: MacBook Pro
macOS Mojave -- version 10.14.4
Safari -- version 12.1
Firefox -- version 70.0

Offline

 

#3 2019-11-08 10:43:01 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 448

Re: Save an Open Textedit Document

davec0864,

Are you trying to save the contents of the text file on the website locally?


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)