Re: I made a nightmare
Re: I made a nightmare
- Subject: Re: I made a nightmare
- From: Shane Stanley <email@hidden>
- Date: Thu, 10 Dec 2015 10:19:13 +1100
On 10 Dec 2015, at 4:10 AM, Yvan KOENIG <email@hidden> wrote:What is puzzling is not the fact that set dest to quoted form of POSIX path of ((sourcefolder as text) & theName) fails in a System Events block. I know for months that we aren’t supposed to use OSAX features in a tell application block. But I know also that Apple explained that tell me to set dest to quoted form of POSIX path of ((sourcefolder as text) & theName) is THE way to get rid of this rule.
So, the official scheme doesn’t work.
You're overlooking the fact that System Events also defines the term POSIX path, and I suspect that's the cause of what you are seeing in this case.
As long as the item at the path exists, you can use this without error:
tell application "System Events" set dest to POSIX path of disk item ((sourcefolder as text) & theName) end tell
The other alternative is ensure that System Events's POSIX path is not used:
tell application "System Events" using terms from scripting additions set dest to POSIX path of ((sourcefolder as text) & theName) end using terms from end tell
As a side note to your actual code, using either the shell's mkdir or ASObjC is easier in this situation because you don't need to check whether the folder already exists; they just make it if it's not there already:
use scripting additions use framework "Foundation"
set theResult to current application's NSFileManager's defaultManager()'s ¬ createDirectoryAtPath:(POSIX path of ((sourcefolder as text) & theName)) ¬ withIntermediateDirectories:true attributes:(missing value) |error|:(missing value)
|
_______________________________________________
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