Le 15/01/2014 à 18:29, Alex Zavatone < email@hidden> a écrit : On Jan 15, 2014, at 12:06 PM, koenig.yvan wrote: Le 15/01/2014 à 17:10, Alex Zavatone < email@hidden> a écrit : On Jan 15, 2014, at 11:00 AM, koenig.yvan wrote: set p2d to path to desktop as text
tell application "Safari" name of document 1 save document 1 in (p2d & result & ".webarchive") end tell
does the job
If this works, that's odd and sorta scary that just specifying the file name determines the type of file you are saving as.
Why would it be odd ?
The dictionary claims :
save v : Save an object. save specifier : the object for the command [as text] : The file type in which to save the data. [in alias] : The file in which to save the object.
As you may see as and well are described as optional.
Because the as specifier is not used at all in the code you suggested.
If the optional specifiers are not supplied, then how are we to assume how Safari will set the file type of the document will be saved? It would be just guesswork on our part.
OHHHHHHHHHHH.
I was looking at your save line, where as is not specified. It never occurred to me that the as parameter would be included in the path variable above. Since as is a verb in English, it translates to me as a command/function, not a parameter signifier.
When I studied English, "as" was an adverb, not a verb. I just know the verb "have" whose a conjugated form is has. But, as it was more than 50 years ago, maybe some changes were introduced.
This is one area where AppleScript's English-like syntax can add confusion.
But still, you're specifying to save it as text, not as a webarchive. Then you're calling the file a .webarchive.
This is certainly confusing.
I would expect that you would save the file as the type of webarchive and in a file with the extension .webarchive, not as the type of text.
But, if this works, it works and thanks for the time you put into helping the original poster out.
Cheers Yvan. - Alex
In my late message I wrote that I tried to use the as parameter with the instruction:
save document 1 as "webarchive"
and I reported the returned error message.
At this time — and it's true for years — xxx.webarchive file have no File Type information embedded in their descriptors.
I don't have an old one to get what it was. If I remember well File Types where four characters long.
I made an other attempt with :
set p2d to path to desktop as text
tell application "Safari" name of document 1 save document 1 in (p2d & result & ".webarchive") as "com.apple.webarchive" end tell
—> error "The document cannot be saved in the \"archive web\" format." number -50
In my long practice of AppleScript, I learnt at least one thing :
AppleScript is not English, it's just something looking like English. Maybe it's useful for non English natives like me. I'm not annoyed by possible anomalies puzzling English natives.
You are giving a perfect example with :
But still, you're specifying to save it as text, not as a webarchive. Then you're calling the file a .webarchive.
I never specified the type by the as text formula. I reproduced a portion of the dictionary which is : [ as text] : The file type in which to save the data.
For me — and I assume that it's the same for every careful reader — that means that the adverb as is supposed to precede a text item which is the way I used it in the instructions : save document 1 as "webarchive" save document 1 as "webarchive" in (p2d & result & ".webarchive")save document 1 in (p2d & result & ".webarchive") as "com.apple.webarchive"
I apologize if I may appear to be rude but in this case the confusion is introduced by yourself, not by the dictionary entry. Before expecting this or that, we are supposed to read carefully the dictionary !
Yvan KOENIG (VALLAURIS, France) mercredi 15 janvier 2014 19:18:22
|