• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: I made a nightmare
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I made a nightmare


  • Subject: Re: I made a nightmare
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 09 Dec 2015 16:51:54 +0100


Le 2015/12/09 à 16:34, Axel Luttgens <email@hidden> a écrit :


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



To be honest too, here is a script with the several attempts I made.

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) --> "'/Users/ME/Desktop/formoosmahna/trucmuche'"


--set dest to quoted form of POSIX path of ((sourcefolder as text) & theName) --> 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"


--set dest to quoted form of POSIX path of file ((sourcefolder as text) & theName) --> error "Erreur dans System Events : Impossible de convertir quoted form of POSIX path of file \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\" en type specifier." number -1700 from quoted form of POSIX path of file "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche" to specifier


--set dest to quoted form of POSIX path of item ((sourcefolder as text) & theName) --> error "Erreur dans System Events : Impossible de convertir quoted form of POSIX path of item \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\" en type specifier." number -1700 from quoted form of POSIX path of item "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche" to specifier


-- set dest to quoted form of POSIX path of alias ((sourcefolder as text) & theName) --> error "Erreur dans System Events : Impossible de convertir quoted form of POSIX path of alias \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\" en type specifier." number -1700 from quoted form of POSIX path of alias "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche" to specifier


--set dest to quoted form of POSIX path of (((sourcefolder as text) & theName) as «class furl»)--> error "Erreur dans System Events : Impossible de convertir POSIX path of file \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\" en type specifier." number -1700 from POSIX path of file "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche" to specifier


--set dest to (((sourcefolder as text) & theName) as «class furl») --> file SSD 500:Users:ME:Desktop:formoosmahna:trucmuche
--set dest to quoted form of POSIX path of dest --> error "Erreur dans System Events : Impossible de convertir POSIX path of file \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\" en type specifier." number -1700 from POSIX path of file "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche" to specifier


tell me # So I'm no longer speaking to System Events
--set dest to quoted form of POSIX path of ((sourcefolder as text) & theName) --> 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"


--set dest to ((sourcefolder as text) & theName) --> SSD 500:Users:ME:Desktop:formoosmahna:trucmuche
# Now, the string exists, do EXACTLY what is done in my handler !
--set dest to quoted form of POSIX path of dest --> 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"


--set dest to quoted form of POSIX path of file ((sourcefolder as text) & theName) --> error "Il est impossible d’obtenir file \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\"." number -1728 from file "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche"


--set dest to quoted form of POSIX path of item ((sourcefolder as text) & theName) --> error "Il est impossible d’obtenir item \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\"." number -1728 from item "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche"


--set dest to quoted form of POSIX path of alias ((sourcefolder as text) & theName) --> error "Il est impossible d’obtenir POSIX path of alias \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche:\"." number -1728 from «class posx» of alias "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche:"


-- set dest to quoted form of POSIX path of (((sourcefolder as text) & theName) as «class furl») --> error "Il est impossible d’obtenir POSIX path of file \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\"." number -1728 from «class posx» of file "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche"


--set dest to (((sourcefolder as text) & theName) as «class furl») --> file SSD 500:Users:ME:Desktop:formoosmahna:trucmuche


--set dest to quoted form of POSIX path of dest --> error "Il est impossible d’obtenir POSIX path of file \"SSD 500:Users:ME:Desktop:formoosmahna:trucmuche\"." number -1728 from «class posx» of file "SSD 500:Users:ME:Desktop:formoosmahna:trucmuche"
end tell
end tell

on quoteIt(aPath) # Here aPath is a string
return quoted form of POSIX path of aPath
end quoteIt


System Events refuse every attempts to get POSIX path of something.
For my point of view it’s not too surprising and it’s why I used tell me to.
What is puzzling is the fact that even when I use tell me to, set dest to quoted form of Posix path of aString -- which is a correctly formed path - fails too


Yvan KOENIG running El Capitan 10.11.2 in French (VALLAURIS, France) mercredi 9 décembre 2015 16:51:47

 _______________________________________________
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

  • Follow-Ups:
    • Re: I made a nightmare
      • From: Axel Luttgens <email@hidden>
    • Re: I made a nightmare
      • From: Christopher Stone <email@hidden>
References: 
 >I made a nightmare (From: Yvan KOENIG <email@hidden>)
 >Re: I made a nightmare (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: I made a nightmare
  • Next by Date: Re: I made a nightmare
  • Previous by thread: Re: I made a nightmare
  • Next by thread: Re: I made a nightmare
  • Index(es):
    • Date
    • Thread