Re: I made a nightmare
Re: I made a nightmare
- Subject: Re: I made a nightmare
- From: Axel Luttgens <email@hidden>
- Date: Wed, 09 Dec 2015 16:34:09 +0100
> Le 9 déc. 2015 à 14:46, Yvan KOENIG a écrit :
>
> Hello
>
> I’ running under 10.11.2
>
> I try to run this simple script :
>
> set theName to "trucmuche"
> --set sourcefolder to (path to desktop as text) & "formoosmahna:" as alias
> set sourcefolder to choose folder
> tell application "System Events"
> if not (exists folder theName of sourcefolder) then
> make new folder at end of sourcefolder with properties {name:theName}
> end if
> -- set dest to quoted form of POSIX path of ((sourcefolder as text) & theName)
> tell me to set dest to quoted form of POSIX path of ((sourcefolder as text) & theName)
> end tell
>
> and I get an awful :
>
> Résultat :
> error « Il est impossible d’obtenir POSIX path of \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\"." number -1728 from «class posx» of "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche"
>
> Same result if I don’t insert « tell me to ».
> I made several attempts and the only one behaving flawlessly is :
>
> set theName to "trucmuche"
> --set sourcefolder to (path to desktop as text) & "formoosmahna:" as alias
> set sourcefolder to choose folder
> tell application "System Events"
> if not (exists folder theName of sourcefolder) then
> make new folder at end of sourcefolder with properties {name:theName}
> end if
> set dest to my quoteIt((sourcefolder as text) & theName)
> end tell
>
> on quoteIt(aPath)
> return quoted form of POSIX path of aPath
> end quoteIt
>
> As far as I remember, the initial syntax behaved well in recent past.
> Is it a new behavior introduced by 10.11.2 ?
Hello Yvan,
To be honest, this may appear as some kind of relief…
Strictly speaking, "POSIX path" is a property of a file object.
It is defined as such in the dictionaries of Standard Additions and System Events.
Somewhere in the evolution of AppleScript, it became possible to ask for the POSIX path of string (probably thanks to those gratuitous string to file coercions provided by Cocoa).
With interesting (?) results once used and abused as a kind of string to path conversion tool; for example:
POSIX path of "/aaa/bbb/ccc"
—> /aaa/bbb/ccc
POSIX path of "aaa/bbb/ccc"
—> /aaa:bbb:ccc
POSIX path of "aaa/bbb:ccc"
—> /aaa:bbb/ccc
I guess your "workaround", based on the quoteIt() handler, just allows to avoid the more reasonable behavior of System Events.
Axel
_______________________________________________
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