Friday, December 15, 2017

#1 2017-11-16 09:06:21 am

matanarie
Member
Registered: 2013-02-04
Posts: 5

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


Filed under: rename, server, duplicate

Offline

 

#2 2017-11-16 04:15:00 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4454

Re: Copying and renaming a file on a server

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.


NG

Offline

 

#3 2017-11-17 03:44:11 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 544

Re: Copying and renaming a file on a server

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

Offline

 

#4 2017-11-17 05:19:04 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4454

Re: Copying and renaming a file on a server

alastor933 wrote:

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.


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)