Hello
In addition to what red_menace has said...
1) I think you may still use System Events 'duplicate' command if you wish.
Something like SCRIPT1a below. (Handler is modified so that it requires only one parameter.)
*Note that the 'duplicate' command of Finder and System Events duplicates the source into the destination. E.g. A statement 'duplicate folder "A:B:C:" to folder "D:E:F:"' will result in the duplicated folder "D:E:F:C:".
--SCRIPT1a
cop2drop("Macintosh HD:Users:home:Documents")
on cop2drop(sourceFolder)
set destFolder to "zome's Public Folder:Drop Box:"
with timeout of 36000 seconds
tell application "System Events"
duplicate folder sourceFolder to folder destFolder
end tell
end timeout
end cop2drop
--END OF SCRIPT1a
2) I don't know the said error -8068 thrown by Finder. It's likely a Finder's private error code which is not listed in any of public headers. And if it is Finder thing, you may or may not see different error, which would be more helpful, when using System Events to copy things into Public Folder. Also you may create a normal folder, e.g. named 'Duplicate' in Public Folder and use it as desination.
3) If you use rsync(1) and want to preserve extended attributes, resource forks and ACLs, you need to use -E option. So at least 'rsync -aE' would be required. And I rememeber the looong thread failed to tame rsync for your backup project...
4) As for how to get POSIX path of file/folder in AppleScript, there're different ways.
Strictly speaking, POSIX path is a property of alias object. So the code to get POSIX path of a folder whose HFS path is 'Macintosh HD:Users:home:Documents:' would be :
POSIX path of ("Macintosh HD:Users:home:Documents:" as alias)
POSIX path of ("Macintosh HD:Users:home:Documents" as alias)
--> /Users/home/Documents/
The first one is the cleanest code because HFS path of directory is supposed to end with ":". The second one also works because 'as alias' coercion will detect whether the specified node is file or directory and return a proper alias object.
And as for the code :
set src to (sourceFolder as alias)'s POSIX Path's text 1 thru -2
It is to strip the trailing '/' from POSIX path of directory and get '/Users/home/Documents', for example. I do this because in shell commands, trailing '/' of directory path is not required and indeed if it's present, it makes certain command behave differently.
E.g.
Provided /a/b/c and /d/e/f are both directory, cp /a/b/c /d/e/f will copy the source directory into the destination directory while cp /a/b/c/ /d/e/f will copy the contents of the source directory into the destination directory.
The rsync(1) behaves in the same manner as cp(1) regarding the trailing '/' of source directory.
The ditto(1) and cp(1) behave differently for the same arguments, i.e., ditto /a/b/c /d/e/f will copy the contents of the source directory into the destination directory.
5) In case, here are revised versions of previous SCRIPT2 and SCRIPT3, which require only one parameter. It will also append any error output to file named 'crop2dropError.txt' on current user's desktop.
*These commands with the current options will preserve extended attributes, resource forks and ACLs when run under 10.5 or later.
--SCRIPT2a - using cp(1)
cop2drop("Macintosh HD:Users:home:Documents")
on cop2drop(sourceFolder)
set destFolder to "zome's Public Folder:Drop Box:"
set src to (sourceFolder as alias)'s POSIX Path's text 1 thru -2
set dst to (destFolder as alias)'s POSIX Path's text 1 thru -2
set sh to "cp -pR " & quoted form of src & " " & quoted form of dst
do shell script (sh & " 2>>~/Desktop/cop2dropError.txt")
end cop2drop
--END OF SCRIPT2a
--SCRIPT3a - using ditto(1)
cop2drop("Macintosh HD:Users:home:Documents")
on cop2drop(sourceFolder)
set destFolder to "zome's Public Folder:Drop Box:"
set src to (sourceFolder as alias)'s POSIX Path's text 1 thru -2
set dst to (destFolder as alias)'s POSIX Path's text 1 thru -2
set sh to "src=" & quoted form of src & ";dst=" & quoted form of dst & ¬
";ditto "${src}" "${dst}/${src##*/}""
do shell script (sh & " 2>>~/Desktop/cop2dropError.txt")
end cop2drop
--END OF SCRIPT3a
Good luck,
H
Message was edited by: Hiroto (fixed typo)