Christopher Werby
Christopher Werby

Reputation: 920

Applescript: Finder's Duplicate command Doesn't Return Reference in Yosemite

I'm upgrading Applescripts that worked in Snow Leopard but fail in Yosemite.

I've tracked down one problem to the Finder's "duplicate" command. When the reference is to a file on a network share mounted using SMB, it no longer appears to return a reference to the duplicated object. I think this might be a bug in Yosemite's OSAX implementation, but I haven't come up with a workaround yet.

set testPath to "MyVolume:Path:To:File:testfile.txt"

tell application "Finder"
   set fileRef to duplicate (testPath as alias)
   log fileRef as string 
end tell

On a Yosemite Mac, the duplicate command works to create a duplicate, but the returned fileRef is undefined. At the location of the log line, I get the error: The variable fileRef is not defined.

On a Snow Leopard Mac, the duplicate command works to create a duplicate, and the returned fileRef variable is fine. The console log output is: MyVolume:Path:To:File:testfile copy.txt

The Finder dictionary on the Yosemite machine says:

duplicate v : Duplicate one or more object(s)

[...]

→ specifier : to the duplicated object(s)

The duplicate command is supposed to return the specifier, but it no longer does.

Has anyone else run into this problem? Am I missing something? Is there a workaround?

Thanks!

Upvotes: 1

Views: 557

Answers (1)

Tim Joe
Tim Joe

Reputation: 475

This kind of thing (at least in mavericks) you have to make sure that when duplication files you use the words "File" and "Folder" or it fails to work. An example is:

 tell application "Finder"
   set CurrentFile to duplicate file CurrentFile to folder CurrentFolder
 end tell

In the case of doing it in the same folder, just drop off the "to folder CurrentFolder"

Upvotes: 0

Related Questions