Can't Convert Server Finder Reference to Alias

I have a little automator script that duplicates a folder then does some processing within the new duped folder. I’m running into an issue where if I’m duplicating locally I can get a Alias path but if I duplicate to the server I get an error. Here are modified snippets…

Local:

set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
set destinationFolder to POSIX file "/Users/Me/Desktop/DestinationFolder"

tell application "Finder"
	set newItem to duplicate myItem to destinationFolder
end tell

return newItem as alias

This returns:

Server:

set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
set destinationFolder to POSIX file "/Volumes/Server/Directory/To/DestinationFolder"

tell application "Finder"
	set newItem to duplicate myItem to destinationFolder
end tell

return newItem as alias

This returns:

The only difference is the destination folder is on the server. Any ideas why this is happening and how to fix? Thanks.

Browser: Safari 537.36
Operating System: macOS 10.14

Please, for readers like me which don’t use server, may you post what is returned by:

set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
set destinationFolder to POSIX file "/Volumes/Server/Directory/To/DestinationFolder"

tell application "Finder"
	set newItem to duplicate myItem to destinationFolder
	properties of newItem
end tell

It may help to understand what strikes.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 16 juin 2020 00:08:30

I get an error when I do that:

A little more info:

When I

I get this…

Local

Server

Also, before upgrading to Mojave it was working fine.

A puzzling problem. :confused:

The script works fine for me on my Mojave machine, both in Script Editor and in the Automator application, duplicating one folder to another on my El Capitan machine.

Your error message contains class enums instead of the Finder keywords, so maybe they’re not being recognised as belonging to the Finder. Have you tried putting the coercion line inside the Finder ‘tell’ statement?

set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
set destinationFolder to POSIX file "/Volumes/Server/Directory/To/DestinationFolder"

tell application "Finder"
	set newItem to duplicate myItem to destinationFolder
	return newItem as alias
end tell

Are you sure that the server was active when you got that ?
It seems that it doesn’t match with what you get when you issue

I don’t use server so I can’t test.
What would be returned by :

tell application "Finder"
	name of every disk
	URL of every disk
end tell

Here the log history is :


Don't click [Open this Scriplet in your Editor:]
Here is just a log history
tell application "Finder"
	get name of every disk
		--> {"Box", "SSD 1000", "home", "net", "vm"}
	get URL of every disk
		--> {"file:///Users/**********/Box/", "file:///", "file:///home/", "file:///net/", "file:///private/var/vm/"}
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 17 juin 2020 16:22:54

It had the same behavior. Worked as you’d expect locally and returned the same error server side.

Yes, server was up and running.

Returns:

Is there another way to get a reference to the duplicated items? I need to process the folders and files within the duped folder and I don’t know how to do it if I can’t get the path. Thanks again!

Thank you. This time I’m really puzzled.

According to what I read in the Finder’s dictionary:
disk n [inh. container > item] : A disk
properties
id (integer, r/o) : the unique id for this disk (unchanged while disk remains connected and Finder remains running)
capacity (double integer, r/o) : the total number of bytes (free or used) on the disk
free space (double integer, r/o) : the number of free bytes left on the disk
ejectable (boolean, r/o) : Can the media be ejected (floppies, CDs, and so on)?
local volume (boolean, r/o) : Is the media a local volume (as opposed to a file server)?

I assumed that Server would be returned among the available disks.

You may use something like :

use AppleScript version "2.5"
use framework "Foundation"
use scripting additions

set myItem to "/Volumes/Server/Directory/To/MyFolder" -- MUST be a POSIX Path
set destinationFolder to "/Volumes/Server/Directory/To/DestinationFolder" -- MUST be a POSIX Path

set myItem to current application's NSString's stringWithString:myItem -- ADDED
set destinationFolder to current application's NSString's stringWithString:destinationFolder -- ADDED
set fileManager to current application's NSFileManager's defaultManager()
-- extract the name of the item to duplicate
set sourceName to myItem's lastPathComponent()
-- build the path of the copied item
set newPath to destinationFolder's stringByAppendingPathComponent:sourceName
-- check if the copied item already exists
set isAvailable to fileManager's fileExistsAtPath:(newPath as boolean)
if not isAvailable then -- it doesn't exist so copy it
	set {theResult, theError} to fileManager's copyItemAtPath:myItem toPath:newPath |error|:(reference)
end if
-- If ou executed for the 2nd time this instruction
set isAvailable to fileManager's fileExistsAtPath:(newPath as boolean)
-- isAvailable will be set to true

For more info about ASObjC, download Shane Stanley’s “Everyday AppleScriptObjC” from
https://macosxautomation.com/applescript/apps/everyday_book.html

On my side I never used ASObjC upon servers but you may execute the proposed script with no risk.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 17 juin 2020 22:03:16

Added two forgotten instructions

I’ll try that and report back. Thanks Yvan!

Back to your original code.
If I run a similar code on local volume with a non available destination folder:

--set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
--set destinationFolder to POSIX file "/Volumes/Server/Directory/To/DestinationFolder"
set myItem to (path to desktop as string) & "pour Musée"
set destinationFolder to (path to documents folder as string) & "unavailableDestinationFolder"
tell application "Finder"
	set newItem to duplicate myItem as alias to folder destinationFolder
end tell

return newItem as alias

The script enter what resemble to an infinite loop and I must relaunch the Finder to exit it.
May I assume that you got the described error when the target folder is unavailable ?
It would not be the first time where we receive an error message which doesn’t match the real problem.

For local volumes, I would be forced to use an enhanced script:

--set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
--set destinationFolder to POSIX file "/Volumes/Server/Directory/To/DestinationFolder"
set myItem to (path to desktop as string) & "pour Musée"
set destinationFolder to (path to documents folder as string) & "unavailableDestinationFolder"
tell application "Finder"
	if exists folder destinationFolder then
		set newItem to duplicate myItem as alias to folder destinationFolder
	else
		error "the folder “" & destinationFolder & "” is not available"
	end if
end tell

return newItem as alias

Given the way items are defined in your script it would be useful to edit your script as :

set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
set destinationFolder to POSIX file "/Volumes/Server/Directory/To/DestinationFolder"

tell application "Finder"
	if exists destinationFolder then
		set newItem to duplicate myItem to destinationFolder
	else
		error "The folder “" & destinationFolder & "” is not available"
	end if
end tell

return newItem as alias

With ASObjC it’s easy to get rid of that.

use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

-- Yvan KOENIG (VALLAURIS, France) 19 juin 2020 12:20:33

set origItem to (path to desktop as string) & "pour Musée" -- Exists on my machine, edit to point to an existing item on your machine
set destFolder to (path to documents folder as string) & "unavailableFolder" -- Deliberately missing folder

if not (my itemExistsAtPath:origItem) then error "“" & origItem & "” is unavailable" number -1728

my createFolder:destFolder -- If destFolder is unavailable, try to create it. May return an error

-- case 1
try
	my duplicateFileAt:origItem toFolder:destFolder
on error
	log "non fatal error"
	-- The target item already exists. I assume that we may continue without doing anything.
end try
-- case 2
-- If the item already exists in destFolder, copy the new one appending a dateTime stamp to its name
my duplicateStampedItemAt:origItem toFolder:destFolder

-- case 3
-- If the item already exists in destFolder, delete the existing item and copy the new one
my duplicateItemAtWithReplacing:origItem toFolder:destFolder

#=====

on itemExistsAtPath:HfsPath
	set fileManager to current application's NSFileManager's defaultManager()
	set POSIXitem to current application's NSString's stringWithString:(POSIX path of HfsPath)
	return fileManager's fileExistsAtPath:POSIXitem
end itemExistsAtPath:

#=====

on createFolder:destFolder -- here, destFolder is an Hfs path
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set fileManager to current application's NSFileManager's defaultManager()
	if not (fileManager's fileExistsAtPath:POSIXdest) then
		-- the destination folder doesn't exist, create it
		set destURL to current application's NSURL's fileURLWithPath:POSIXdest
		set {theResult, theError} to fileManager's createDirectoryAtURL:destURL withIntermediateDirectories:true attributes:(missing value) |error|:(reference)
		if (theResult as boolean) is false then
			error (theError's localizedDescription() as string)
		end if
	end if
end createFolder:

#=====

on duplicateFileAt:sourcePath toFolder:destFolder -- here, sourcePath is an alias and destFolder is an Hfs path
	set POSIXsource to current application's NSString's stringWithString:(POSIX path of sourcePath)
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set theNewPath to POSIXdest's stringByAppendingPathComponent:(POSIXsource's lastPathComponent())
	set fileManager to current application's NSFileManager's defaultManager()
	set {theResult, theError} to fileManager's copyItemAtPath:POSIXsource toPath:theNewPath |error|:(reference)
	if (theResult as boolean) is false then
		error (theError's localizedDescription() as string)
	end if
end duplicateFileAt:toFolder:

#=====

on duplicateItemAtWithReplacing:sourcePath toFolder:destFolder -- here, sourcePath is an alias and destFolder is an Hfs path
	set fileManager to current application's NSFileManager's defaultManager()
	set POSIXsource to current application's NSString's stringWithString:(POSIX path of sourcePath)
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set theNewPath to POSIXdest's stringByAppendingPathComponent:(POSIXsource's lastPathComponent())
	set fileManager to current application's NSFileManager's defaultManager()
	if fileManager's fileExistsAtPath:theNewPath then
		-- delete the existing item
		fileManager's removeItemAtPath:theNewPath |error|:(reference)
	end if
	set {theResult, theError} to fileManager's copyItemAtPath:POSIXsource toPath:theNewPath |error|:(reference)
	if (theResult as boolean) is false then
		error (theError's localizedDescription() as string)
	end if
end duplicateItemAtWithReplacing:toFolder:

#=====

on duplicateStampedItemAt:sourcePath toFolder:destFolder -- here, sourcePath is an alias and destFolder is an Hfs path
	set fileManager to current application's NSFileManager's defaultManager()
	set POSIXsource to current application's NSString's stringWithString:(POSIX path of sourcePath)
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set theNewPath to POSIXdest's stringByAppendingPathComponent:(POSIXsource's lastPathComponent())
	set fileManager to current application's NSFileManager's defaultManager()
	if fileManager's fileExistsAtPath:theNewPath then
		set thePathNoExt to theNewPath's stringByDeletingPathExtension()
		set stamp to my buildStamp()
		set theExtension to POSIXsource's pathExtension()
		-- insert the stamp in the file name so it will not duplicate
		set theNewPath to (thePathNoExt's stringByAppendingString:stamp)'s stringByAppendingPathExtension:theExtension
	end if
	set {theResult, theError} to fileManager's copyItemAtPath:POSIXsource toPath:theNewPath |error|:(reference)
	if (theResult as boolean) is false then
		error (theError's localizedDescription() as string)
	end if
end duplicateStampedItemAt:toFolder:

#=====

on buildStamp()
	tell (current date) to return "_" & (((its year) * 10000 + (its month) * 100 + (its day)) as string) & "_" & text 2 thru -1 of ((1000000 + (its hours) * 10000 + (its minutes) * 100 + (its seconds)) as string)
end buildStamp

#=====

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 19 juin 2020 11:51:00

May it be that the folder /Directory/To/DestinationFolder/ was unavailable on the Server ?
May you try to execute:

set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
set POSIXDest to "/Volumes/Server/"
set level1 to "Directory/"
set destinationFolder1 to POSIX file ("/Volumes/Server/" & level1)
set level2 to "To/"
set destinationFolder2 to POSIX file ("/Volumes/Server/" & level1 & level2)
set level3 to "DestinationFolder/"
set destinationFolder to POSIX file ("/Volumes/Server/" & level1 & level2 & level3)

tell application "Finder"
	exists destinationFolder1
	log result
	exists destinationFolder2
	log result
	exists destinationFolder
	log result
	set newItem to duplicate myItem to destinationFolder
	return newItem as alias
end tell

Of course you will have to replace “Directory”, “To”, MyFolder" and “DestinationFolder” by real names of subfolders.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 20 juin 2020 18:38:50

Hi Yvan, I really appreciate all of the suggestions. I got slammed at work and can’t dig in until later this week.

I will confirm though that the server is definitely available. In fact my source folder is on the server. Also I should add that the duplicate command works, the source folder gets duplicated into the destination folder. Assigning the newItem variable is where it fails and I get the error.

If it’s only that, you may add some instructions at the end of the handlers.

use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

-- Yvan KOENIG (VALLAURIS, France) 22 juin 2020 22:05:33

property wantFurl : true
-- if true, the duplicate handler return «class furl» object
-- if false, the duplicate handler return POSIXPath object

set origItem to (path to desktop as string) & "pour Musée" -- Exists on my machine, edit to point to an existing item on your machine
set destFolder to (path to documents folder as string) & "unavailableFolder" -- Deliberately missing folder

if not (my itemExistsAtPath:origItem) then error "“" & origItem & "” is unavailable" number -1728

set newItem to my createFolder:destFolder -- If destFolder is unavailable, try to create it. May return an error
log newItem --> "/Users/yvankoenig/Documents/unavailableFolder/"
--> file "SSD 1000:Users:yvankoenig:Documents:unavailableFolder:"

-- case 1
set newItem to my duplicateFileAt:origItem toFolder:destFolder
log newItem --> "/Users/yvankoenig/Documents/unavailableFolder/pour Musée"
--> file "SSD 1000:Users:yvankoenig:Documents:unavailableFolder:pour Musée:"

-- case 2
-- If the item already exists in destFolder, copy the new one appending a dateTime stamp to its name
set newItem to my duplicateStampedItemAt:origItem toFolder:destFolder
log newItem --> "/Users/yvankoenig/Documents/unavailableFolder/pour Musée_20200622_214650"
--> file "SSD 1000:Users:yvankoenig:Documents:unavailableFolder:pour Musée_20200622_214942:"

-- case 3
-- If the item already exists in destFolder, delete the existing item and copy the new one
set newItem to my duplicateItemAtWithReplacing:origItem toFolder:destFolder
log newItem --> "/Users/yvankoenig/Documents/unavailableFolder/pour Musée"
--> file "SSD 1000:Users:yvankoenig:Documents:unavailableFolder:pour Musée:"

#=====

on itemExistsAtPath:HfsPath
	set fileManager to current application's NSFileManager's defaultManager()
	set POSIXitem to current application's NSString's stringWithString:(POSIX path of HfsPath)
	return fileManager's fileExistsAtPath:POSIXitem
end itemExistsAtPath:

#=====

on createFolder:destFolder -- here, destFolder is an Hfs path
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set fileManager to current application's NSFileManager's defaultManager()
	if not (fileManager's fileExistsAtPath:POSIXdest) then
		-- the destination folder doesn't exist, create it
		set destURL to current application's NSURL's fileURLWithPath:POSIXdest
		set {theResult, theError} to fileManager's createDirectoryAtURL:destURL withIntermediateDirectories:true attributes:(missing value) |error|:(reference)
		if (theResult as boolean) is false then
			error (theError's localizedDescription() as string)
		end if
	end if
	if wantFurl then
		return (current application's NSURL's fileURLWithPath:POSIXdest) as «class furl»
	else
		return POSIXdest as string
	end if
end createFolder:

#=====

on duplicateFileAt:sourcePath toFolder:destFolder -- here, sourcePath is an alias and destFolder is an Hfs path
	set POSIXsource to current application's NSString's stringWithString:(POSIX path of sourcePath)
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set theNewPath to POSIXdest's stringByAppendingPathComponent:(POSIXsource's lastPathComponent())
	set fileManager to current application's NSFileManager's defaultManager()
	set {theResult, theError} to fileManager's copyItemAtPath:POSIXsource toPath:theNewPath |error|:(reference)
	
	if (theResult as boolean) is false then
		if theError's code() as integer ≠ 516 then error (theError's localizedDescription() as string)
	end if
	if wantFurl then
		return (current application's NSURL's fileURLWithPath:theNewPath) as «class furl»
	else
		-- log "case 1 : " & theNewPath as string
		return theNewPath as string
	end if
end duplicateFileAt:toFolder:

#=====

on duplicateStampedItemAt:sourcePath toFolder:destFolder -- here, sourcePath is an alias and destFolder is an Hfs path
	set fileManager to current application's NSFileManager's defaultManager()
	set POSIXsource to current application's NSString's stringWithString:(POSIX path of sourcePath)
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set theNewPath to POSIXdest's stringByAppendingPathComponent:(POSIXsource's lastPathComponent())
	set fileManager to current application's NSFileManager's defaultManager()
	if fileManager's fileExistsAtPath:theNewPath then
		set thePathNoExt to theNewPath's stringByDeletingPathExtension()
		set stamp to my buildStamp()
		set theExtension to POSIXsource's pathExtension()
		-- insert the stamp in the file name so it will not duplicate
		set theNewPath to (thePathNoExt's stringByAppendingString:stamp)'s stringByAppendingPathExtension:theExtension
	end if
	set {theResult, theError} to fileManager's copyItemAtPath:POSIXsource toPath:theNewPath |error|:(reference)
	if (theResult as boolean) is false then
		error (theError's localizedDescription() as string)
	end if
	if wantFurl then
		return (current application's NSURL's fileURLWithPath:theNewPath) as «class furl»
	else
		-- log "case 2 : " & theNewPath as string
		return theNewPath as string
	end if
end duplicateStampedItemAt:toFolder:

#=====

on duplicateItemAtWithReplacing:sourcePath toFolder:destFolder -- here, sourcePath is an alias and destFolder is an Hfs path
	set fileManager to current application's NSFileManager's defaultManager()
	set POSIXsource to current application's NSString's stringWithString:(POSIX path of sourcePath)
	set POSIXdest to current application's NSString's stringWithString:(POSIX path of destFolder)
	set theNewPath to POSIXdest's stringByAppendingPathComponent:(POSIXsource's lastPathComponent())
	set fileManager to current application's NSFileManager's defaultManager()
	if fileManager's fileExistsAtPath:theNewPath then
		-- delete the existing item
		fileManager's removeItemAtPath:theNewPath |error|:(reference)
	end if
	set {theResult, theError} to fileManager's copyItemAtPath:POSIXsource toPath:theNewPath |error|:(reference)
	if (theResult as boolean) is false then
		error (theError's localizedDescription() as string)
	end if
	if wantFurl then
		set destURL to current application's NSURL's fileURLWithPath:theNewPath
		return destURL as «class furl»
	else
		-- log "case 3 : " & theNewPath as string
		return theNewPath as string
	end if
end duplicateItemAtWithReplacing:toFolder:

#=====

on buildStamp()
	tell (current date) to return "_" & (((its year) * 10000 + (its month) * 100 + (its day)) as string) & "_" & text 2 thru -1 of ((1000000 + (its hours) * 10000 + (its minutes) * 100 + (its seconds)) as string)
end buildStamp

#=====

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 22 juin 2020 21:10:17

I did some initial testing on this and it appears to be working! I’m using specifically Case #1.

Thanks for the help Yvan!

CAUTION, at least under 10.13.6, the way the system return errors is foolish.
If you try to copy an existing file (selected with Choose file) to a folder which doesn’t exists, it issue a code error 4 and claims that it’s the source item which is missing.
I found no better scheme than checking that the source and the target really exist before executing the duplicate command.

CAUTION 2. With case 1, if you try to duplicate an item which already exists in the target folder, the system will issue error code 516 and the handler will politely return the descriptor of the item but nothing will be copied. It’s useful only if you know that there is no existing replicate of the source.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 23 juin 2020 01:43:02

I’ve updated my code and now the duped folder path gets passed to the newItem variable. So far so good.

The issue I’m running into now is when I start processing the files in that path. For example:

tell application "Finder"
	set fileName to name of newItem
end tell

This give’s me the following error:

Finder got an error: Can’t get alias “path:to:newItem:”.

Again this works if I do it to a local folder but not a folder on my server (since the 10.14 update).

The common denominator to both issues seems to be the that it’s using the tell application “Finder” command. If you remember the command I had issues with was:

tell application "Finder"
	set newItem to duplicate thisItem to destinationFolder
end tell

Although interestingly the duplicate command worked just not the set command. Any ideas on a solve? I’ve having trouble deciphering how you circumvented the finder in the code you posted. Thanks.

As far as I know, the Finder’s dictionary doesn’t state that the duplicate command is supposed to return a meaningful result.
It does on local devices, it did on servers but it no longer does with servers. You can’t complain here. You were assuming that a non-documented feature was guaranteed to be available everytime. Just a wrong guess.

In my messages you have already all the infos required to do what you want.

According to a property defined at the very beginning of the scripts, my proposed handlers return a POSIXPath or a «class furl» object. The script below show how to get the name of such items.

use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

set aFile to (choose file)
log aFile (*alias SSD 1000:Users:yvankoenig:Desktop:fool / copie.scpt*)
set aFurl to aFile as «class furl»
log aFurl (*file SSD 1000:Users:yvankoenig:Desktop:fool / copie.scpt*)
-- grab the name of a «class furl» object
set POSIXsource to current application's NSString's stringWithString:(POSIX path of aFurl)
set itsName to (POSIXsource's lastPathComponent()) as string
log itsName (*fool : copie.scpt*)
-- Instruction required if the Hfs name contain a slash
if itsName contains ":" then set itsName to my replace:itsName existingString:":" newString:"/"
log itsName (*fool / copie.scpt*)

set POSIXPath to POSIX path of aFile
log result
-- grab the name of a POSIX path object
set POSIXsource to current application's NSString's stringWithString:POSIXPath
set itsName to (POSIXsource's lastPathComponent()) as string
log itsName (*fool : copie.scpt*)
-- Instruction required if the Hfs name contain a slash
if itsName contains ":" then set itsName to my replace:itsName existingString:":" newString:"/"
log itsName (*fool / copie.scpt*)

on replace:sourceString existingString:d1 newString:d2
	set sourceString to current application's NSString's stringWithString:sourceString
	return (sourceString's stringByReplacingOccurrencesOfString:d1 withString:d2) as text
end replace:existingString:newString:

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 25 juin 2020 01:50:02

It seems that you drown in a glass of water.
Back to the very beginning.

set myItem to POSIX file "/Volumes/Server/Directory/To/MyFolder"
set destinationFolder to POSIX file "/Volumes/Server/Directory/To/DestinationFolder"

is the same as

set myItem to "Server:Directory:To:MyFolder" as «class furl»
set destinationFolder to "Server:Directory:To:DestinationFolder:" as «class furl»

To duplicate, a correct syntax would be

tell application "Finder"
	set newItem to duplicate myItem to destinationFolder
	set newItem to newItem as alias
end tell

because, if it returns something, duplicate return a Finder reference which must be converted into alias by the Finder itself.
The syntax above would be correct as long as the replicate is not already available.
To get rid of that, you may code

try
tell application "Finder"
	set newItem to duplicate myItem to destinationFolder
	set newItem to newItem as alias
end tell
end try

But if the replicate already exists, no newItem object would be returned.
You must use this alternate code:

tell application "Finder"
	set origName to name of item (myItem as string)
	set destHfs to destinationFolder as string
	if destHfs does not end with ":" then set destHfs to destHfs & ":"
	set newItem to destHfs & origName
	if not (exists item newItem) then duplicate myItem to destinationFolder
	set newItem to newItem as alias
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 25 juin 2020 11:03:10

I really appreciate all the time you’ve taken to respond. I will dig in and see if I can get everything up and running using what you’ve shown. Thanks!

Hi Yvan, sorry for the back and forth. I’ve been able to get most of my original script up and running but ran into a snag.

Since I can’t rename files/folder on the server using the traditional method i.e.

set myItem to POSIX file "/Volumes/serverName/folder/" as alias

tell application "Finder"
	set the name of thisItem to "newName"
end tell

(throws an error: “Finder got an error: Can’t set alias "serverName:folder:" to "newName"." number -10006 from alias "serverName:folder:”)

What is the method using NSFileManager to circumvent using Finder?

It’s really boring to see that you are unable to use what is given to you.

I posted :

I never converted a POSIX File into an alias.

I posted:

I remember having see error -10006 (scripts dealing with Quicktime if I remember well) but I have no idea of what is wrong.
Maybe it’s a problem of permissions and if it is, ASObjC will not help.
I already gave you in message #9 and message #16 every pieces of code useful to do what you want. As I am not a parrot, I will not repeat.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 26 juin 2020 01:22:08