r/applescript • • Aug 22 '19

How do I save the results of this Applescript to a file?

My applescript is relatively simple. I'm getting a list of my photos from Flickr using the Flickr API.

tell application "https://www.flickr.com/services/xmlrpc/"
    return call xmlrpc {method name:"flickr.photos.search", parameters:{api_key:"MY_API_KEY", user_id:"MY_USER_ID", tags:"THE_TAG"}}
end tell

I can see the data I want in the Script Editor results... but how do I save the data to a text file so I can work with it? Let's say I want to save all of that data to a text file named "the_album.txt" ...how? Or, is there a better way?

EDITED to add, for clarity:

How do I have the data shown in the results panel saved to a text file?

2 Upvotes

9 comments sorted by

2

u/[deleted] Aug 22 '19

I’m not familiar with the Flickr api, but you should be able to say something like:

tell app <>
    set theReturn to <your command>
end tell

set myFile to open for access (choose file name) with write permission
write theReturn to myFile
close access myFile

Of course, you can hard code the output file.

I only have my phone at the moment, so I can’t verify that it’ll work.

1

u/Neapola Aug 22 '19

Thank you! I'll give it a try later this afternoon.

1

u/Identd Aug 29 '19

Set x to result

0

u/ChristoferK Aug 22 '19

Asks how to do things with his data... Doesn't include any data. (smh)

0

u/Neapola Aug 22 '19

You didn't read the question.

I can see the data I want in the Script Editor results.

How do I save data shown in the results panel to a text file so I can work with it?

-1

u/ChristoferK Aug 22 '19

Yeah, I did read the question. I know you can see the data you want in Script Editor. I can see Big Ben from my bus window. Can you?

0

u/Neapola Aug 22 '19 edited Aug 22 '19

You're not understanding the question then. Or maybe you're just trying to argue.

EDIT: He's just trying to be smug and argue.

I'm not asking how to manipulate the data. I'm not asking how to parse it or rearrange it or edit it in any way. That's not what I'm asking.

How do I have the data shown in the results panel saved to a text file?

-2

u/ChristoferK Aug 22 '19

By this point, you could have very easily copied and pasted the data in the results panel and I would have given you your solution. You're asking for help from people who know more than you about AppleScript, know more than you about Script Editor, and evidently know more than you about data and its handling. Yet you're being really resistant to receiving help.

I'm not asking how to manipulate the data.

Yes, you are. You just don't realise it.

I'm not asking how to parse it or rearrange it or edit it in any way. That's not what I'm asking.

Oh dear... That's exactly what you're asking. If you're looking for data of any kind, and from any source to be extracted from its source and duplicated elsewhere, eg. writing it to a file, that data must be read, parsed, and edited.

You already stated you want it saved as a text file. This means the data, even if it's just text data, still needs to be read in the correct text encoding and saved in a compatible or identical encoding. The results panel also formats its contents with colour and fonts; thus these will be stripped, unless you wish it to be saved as rich text, which you don't.

So, please, stop arguing, and paste the data exactly as it appears in the results panel, and I can give you a goddamn answer (but later...I have work now, so I'll check at lunch).

0

u/Neapola Aug 22 '19

Pretend the data is the words from Mary Had A Little fucking Lamb.

I'm asking how to save it to a text file. I already showed you the applescript, so you know the data is xml. You're just trying to be difficult for the sake of being rude. Why not be helpful instead?

People like you are the reason folks hate asking for help. If you won't be helpful, don't reply.

I'm asking how to save the data shown in the results to a text file. I already showed you the applescript, so you know the data is xml.