• 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: 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)

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: Yvan KOENIG <email@hidden>
References: 
 >I made a nightmare (From: Yvan KOENIG <email@hidden>)
 >Re: I made a nightmare (From: "S. J. Cunningham" <email@hidden>)
 >Re: I made a nightmare (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Finder Shows No Windows when Hidden
  • Next by Date: Filemaker - commit or select no cell
  • Previous by thread: Re: I made a nightmare
  • Next by thread: Re: I made a nightmare
  • Index(es):
    • Date
    • Thread