Copying and renaming a file on a server

Hi everyone,
I’m trying to copy a file from Folder A on my server to Folder B on my server, and rename it in the new location.

The following approach works, but only when the original file is on my local computer.

tell application "Finder"
    with timeout of 60 seconds
        set _newPath to (duplicate file _file to folder _matrixLocation with replacing)
        set _newPath's name to _newMatrix
    end timeout
end tell

The error I get is “The variable _New Path is not defined”. I can’t seem to figure out why this is working with local files but not with remote files. Does the Duplicate command not return the new files location when copying to a server?

Thanks!
Matan

Hi.

Your code works for me, moving a file around on one computer with a script run on another. But of course you haven’t said what the values are in _file and _matrixLocation. They should be full HFS paths to the file and folder concerned. Presumably too your local computer must have permission to do things with that file and that folder on the other machine.

Finder’s duplicate command returns a faulty reference when working on an item on a remote volume. See here.

That was seven years and four months ago! It’s working correctly for me today on a High Sierra machine talking to an El Capitan one, whether with the El Capitan volume mounted or an individual user folder.