• 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: Finder "duplicate" requirements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder "duplicate" requirements


  • Subject: Re: Finder "duplicate" requirements
  • From: Shane Stanley <email@hidden>
  • Date: Sun, 28 Jun 2015 17:14:57 +1000

On 28 Jun 2015, at 12:38 am, Jean-Christophe Helary <email@hidden> wrote:

the problem I had was that the following line:

set properties of (duplicate POSIX file "/Path/to/file/stuff.pages" to arbitrary_folder with replacing) to {locked:false}

would work pretty much all the time *except* when the line:

use framework "Foundation"

was somewhere in the script.

(As an aside, use statements should generally be at the beginning of a script, but that's not an issue here.)

The problem can be simplified:

use framework "Foundation"
use scripting additions

tell application "Finder"
exists POSIX file "/Users/shane/Desktop/Testing.png"
exists alias "Macintosh HD:Users:shane:Desktop:Testing.png"
exists file "Macintosh HD:Users:shane:Desktop:Testing.png"

Which returns:

exists current application
--> false
exists current application
--> false
exists file "Macintosh HD:Users:shane:Desktop:Testing.png"
--> true

For some reason, there's a problem resolving POSIX file and alias references.

There are a couple of workarounds:

exists (get POSIX file "/Users/shane/Desktop/Testing.png")
exists "/Users/shane/Desktop/Testing.png" as POSIX file

But I'm not really sure why they're needed. I'm not seeing the same problem in System Events, but I haven't tried any other apps. It's a common problem in Xcode-based apps, but I haven't noticed it in standard AppleScript before.

Curious...

-- 
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: Finder "duplicate" requirements
      • From: Christopher Stone <email@hidden>
References: 
 >Finder "duplicate" requirements (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: Finder "duplicate" requirements
  • Next by Date: Re: Finder "duplicate" requirements
  • Previous by thread: Re: Finder "duplicate" requirements
  • Next by thread: Re: Finder "duplicate" requirements
  • Index(es):
    • Date
    • Thread