Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

3 questions regarding duplicate script

3 questions regarding duplicate script

Here is my script for copying folders from one Mac to another Mac via Ethernet:
(This is not meant as a backup, just to automatically distribute files to the other Mac.
For backup I'm using Time Machine.)

cop2drop("Macintosh HD:Users:home:Desktop", "zome's Public Folder:Drop Box:")
cop2drop("Macintosh HD:Users:home:Documents", "zome's Public Folder:Drop Box:")
cop2drop("Macintosh HD:Users:home:Pictures", "zome's Public Folder:Drop Box:")
cop2drop("Macintosh HD:Users:home:Sites", "zome's Public Folder:Drop Box:")

on cop2drop(sourceFolder, destFolder)
tell application "Finder"
duplicate every file of folder sourceFolder to folder destFolder
duplicate every folder of folder sourceFolder to folder destFolder
end tell
end cop2drop


1. One problem I haven't sorted out yet: How can I modify this script so that
all source folders (incl. their files and sub-folders) get copied
as correspondent destination folders (same names) under the Drop Box?
(At the moment the files and sub-folder arrive directly in the Drop Box
and mix with the other destination files and sub-folders.)

2. Everytime before a duplicate starts, I have to confirm this message:
"You can put items into "Drop Box", but you won't be able to see them. Do you want to continue?"
How can I avoid or override this message? (This script shall run in the night,
when no one is near the computer to press OK again and again.)

3. A few minutes after the script starts running I get:
"AppleScript Error - Finder got an error: AppleEvent timed out."
How can I stop this?

Thanks in advance for your help!

Mac OS X (10.6.2), iMacs

Posted on Jan 25, 2010 8:22 PM

Reply
14 replies

Jan 25, 2010 8:51 PM in response to coxorange

1) Use entire contents:
duplicate entire contents of folder sourceFolder to folder destFolder

2) You might try using *System Events* instead of the Finder (usually this is a good idea anyway). Some of the terms may be slightly different, but most file operations are available without any Finder "extras".

3) AppleScript will only wait for a couple of minutes for an application response, so if you are transferring a lot of files it is probably taking longer. You can wrap your duplicate statement(s) in a with timeout statement to increase the time delay, or perhaps a ignoring application responses statement.

Another option would be to use a shell script.

Jan 26, 2010 6:17 PM in response to red_menace

Thanks!

I've tried to modify my script...

cop2drop("test")
cop2drop("Desktop")
cop2drop("Documents")
cop2drop("Pictures")
cop2drop("Sites")

on cop2drop(currentFolder)
set sourceFolder to "Macintosh HD:Users:home:" & currentFolder & ":"
set destFolder to "zome's Public Folder:Drop Box:" & currentFolder & ":"
make new folder at "zome's Public Folder:Drop Box:" with properties {name:currentFolder}
tell application "System Events" -- instead of Finder
duplicate entire contents of folder sourceFolder to folder destFolder
end tell
end cop2drop


... but it doesn't create folders on the other Mac! (# -1700 error)
Does the script have to "log in" to the other Mac?
How can I fix it...?

Jan 27, 2010 10:00 AM in response to coxorange

The other machine does need to be connected, and the path would be something like zome:Public:Drop Box: (the full path depends on what you have mounted - the disk, a user account, etc). A handy way to get the correct path while developing is to use choose folder, then replace with the appropriate path when you are done testing. Also, to create a new folder, the statement needs to be inside the *System Events* tell statement, since that application is what will be making the folder (and yes, make new folder needs end of when using *System Events* - don't ask):

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on cop2drop(currentFolder)
set sourceFolder to "Macintosh HD:Users:home:" & currentFolder & ":"

-- testing, replace with a specific destination folder path
set destFolder to (choose folder) as text
log result

tell application "System Events" -- instead of Finder
try -- make sure currentFolder exists, skipping the error if it does
make new folder at end of folder destFolder with properties {name:currentFolder}
end try
set destFolder to destFolder & currentFolder & ":"
duplicate entire contents of folder sourceFolder to folder destFolder
end tell
end cop2drop</pre>

Jan 27, 2010 2:31 PM in response to coxorange

Hello

You may just copy the source folder into destination folder. No need to process every file and folder in the source folder separately.

Try something like this :

--SCRIPT1
cop2drop("Macintosh HD:Users:home:Documents", "zome's Public Folder:Drop Box:")
on cop2drop(sourceFolder, destFolder)
with timeout of 36000 seconds
tell application "Finder"
duplicate folder sourceFolder to folder destFolder with replacing
end tell
end timeout
end cop2drop
--END OF SCRIPT1

*This will handle your 1st and 3rd issues. As for the 2nd, I don't know how to suppress it except to use a normal folder as destination. Or possibly using System Events instead of Finder might help.
(By the way, how can we tell System Events to replace the existing destination? It doesn't seem there's 'replacing' parameter for its 'duplicate' command...)

---
You may use cp(1) or ditto(1) as well, which would suit better :

--SCRIPT2 - using cp(1)
cop2drop("Macintosh HD:Users:home:Documents", "zome's Public Folder:Drop Box:")
on cop2drop(sourceFolder, destFolder)
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
end cop2drop
--END OF SCRIPT2

--SCRIPT3 - using ditto(1)
cop2drop("Macintosh HD:Users:home:Documents", "zome's Public Folder:Drop Box:")
on cop2drop(sourceFolder, destFolder)
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
end cop2drop
--END OF SCRIPT3


Hope this may help,
H

Jan 27, 2010 2:45 PM in response to red_menace

Lots of thanks for your help!
I had mounted the other Mac via Finder > Sidebar/Shared > zome's iMac > doubleclicked on "zome's Public Folder" and "Drop Box".
I've made the test you've suggested and the path really is "zome's Public Folder:Drop Box:".
I've replaced it in the script and adjusted the other lines (I hope correctly).

cop2drop("test")

on cop2drop(currentFolder)
set sourceFolder to "Macintosh HD:Users:home:" & currentFolder & ":"
set destFolder to "zome's Public Folder:Drop Box:" & currentFolder & ":"
tell application "System Events" -- instead of Finder
try -- make sure currentFolder exists, skipping the error if it does
make new folder at end of folder "zome's Public Folder:Drop Box:" with properties {name:currentFolder}
end try
duplicate entire contents of folder sourceFolder to folder destFolder
end tell
end cop2drop


The folder "test" now gets created under "Drop Box", but then I get an...

AppleScript Error
System Events got an error: Can’t set folder "zome's Public Folder:Drop Box:test:"
to entire contents of folder "Macintosh HD:Users:home:test:".


This is the log:

tell application "System Events"
make new folder at end of folder "zome's Public Folder:Drop Box:" with properties {name:"test"}
--> folder "zome's Public Folder:Drop Box:test:"
copy entire contents of folder "Macintosh HD:Users:home:test:" to folder "zome's Public Folder:Drop Box:test:"
--> *error number -1728* from «class ects» of «class cfol» "Macintosh HD:Users:home:test:"
Result:
error "System Events got an error: Can’t set folder \"zome's Public Folder:Drop Box:test:\" to entire contents of folder \"Macintosh HD:Users:home:test:\"." *number -10006* from folder "zome's Public Folder:Drop Box:test:"


What is wrong here? For me all looks right now...

Thanks again!

Jan 27, 2010 4:26 PM in response to coxorange

OK, it looks like entire contents isn't valid in *System Events* (it doesn't have a container property). Getting the disk items isn't recursive and also returns invisible items, such as .DS_Store, so there really isn't handy alternate property to use.

If a different destination folder were being used, there wouldn't be a need to go around the FInder, so in this case I think I am going to agree with Hiroto, although I would use rsync, which has the feature of not copying if the file already exists at the destination:

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
cop2drop("test")

on cop2drop(currentFolder)
set sourceFolder to quoted form of POSIX path of ("Macintosh HD:Users:home:" & currentFolder & ":")
set destFolder to quoted form of POSIX path of ("zome's Public Folder:Drop Box:" & currentFolder & ":")
tell application "System Events" to try -- make sure currentFolder exists, skipping the error if it does
make new folder at end of folder "zome's Public Folder:Drop Box:" with properties {name:currentFolder}
end try
do shell script "/usr/bin/rsync --archive " & sourceFolder & space & destFolder
end cop2drop</pre>

Note that a trailing delimiter in the path name changes the copy operation from the folder to the contents of a folder (rsync also has an option to delete files at the destination that are not in the source).

Jan 28, 2010 8:32 AM in response to red_menace

First a note to Hiroto: Thanks also to you for your suggestions!
I try to reply here too in order to avoid splitting the thread.

It is NOT required to consider possible existence of folders or subfolders at the destination side and it is not required to consider possible overwriting of files in destination folders or subfolders, because the script will always ONLY be used to copy into an EMPTY Drop Box (no files or folders there at all). Sorry, I forgot to mention this before, but now I realised it might make things easier. I only need to make 100% equal copies of the original source folders (with files and sub-folders) at the destination side - just as drag and drop would make - that's all.

Summary (what would suit best?):
====================

1. System Event's "duplicate":
Under all aspects I assume it's not possible to use it - am I right?
red_menace wrote: +Getting the disk items isn't recursive and also returns invisible items, such as .DS_Store...+
Wouldn't it be REQUIRED to process the invisible items too in order to transfer the entire contents of a folder?

2. Finder's "duplicate":
red_menace wrote: +If a different destination folder were being used, there wouldn't be a need to go around the FInder...+
I thought it would be the easiest way to use the Drop Box, but I would also be happy to use the Public Folder if that would work. Would the script have the required permissions/rights to WRITE to the Public Folder of another Mac?

Would be nice, but the following didn't work:

cop2drop("Macintosh HD:Users:home:test", "zome's Public Folder:") -- FINDER version w/o Drop Box:

on cop2drop(sourceFolder, destFolder)
with timeout of 36000 seconds
tell application "Finder"
duplicate folder sourceFolder to folder destFolder
end tell
end timeout
end cop2drop


=> error number -8068 - Why...?

(2.a. If that wouldn't work, I have another idea:
Could this script be used in conjunction with a 2nd script which would be started simultaneously and just lurk for that "+You can put items into "Drop Box", but you won't be able to see them. Do you want to continue?+" message and "press" the OK button as soon as it would appear? Maybe this idea sounds a bit cumbersome...)

For the remaining alternatives (3.-5.) I tried to read the information found in Terminal under "man rsync", "man cp" and "man ditto", but I can't overlook all combinations of parameters and can't know which ones are required for my situation (see above). Seems complicated for non-experts...

3. "rsync": WORKS!
I would like to avoid the usage of "rsync" if possible. I've experimented with it before (I was using the parameters "-aE" to get all source files) and it made some problems (for example decompressing of the transferred data in some cases on the other Mac). In my case there is also no need for synchronisation at all (for large folders it takes some additional time to make these lists for comparisons). Also its capability to delete files at the destination that are not/no longer in the source is not required.

4. and 5. "cp" and "ditto": BOTH WORK! (I think I would prefer "cp" over "ditto")
Are the parameters ideal in my case?
Why are there differences in the POSIX definition line:
red_menace wrote: +set sourceFolder to quoted form of POSIX path of ("Macintosh HD:Users:home:" & currentFolder & ":")+
Hiroto wrote: +set src to (sourceFolder as alias)'s POSIX Path's text 1 thru -2+
Are they interchangeable? Or what does that special +Path's text 1 thru -2+ mean??
Should I add " 2>>/Users/home/rsyncErr.txt || echo -n" for the case that errors occur?

I hope that's not too much questions!

Jan 28, 2010 10:26 AM in response to coxorange

1 & 2) The whole idea with using *System Events* was to avoid the drop box nag dialog in the Finder. In your original script, it appeared that you were adding to a possibly existing folder, so copying things such as .DS_Store may not have been appropriate. Without the need to consider or preserve existing items or folder structures, the script becomes much easier.

- By the way, your script works for me if the destination is not a drop box (e.g. the Public folder) - not sure what error -8068 is, but -8086 is "destination permissions error", which would most likely be a drop box error.

3) Using rsync just conditionally copies - there are a ton of options, so it would depend on exactly what you are wanting to do. I've developed an rsync based script and Automator action that work for me for backups, so although you weren't using the script for backups, rsync also has options that deal with preserving existing items.

4 & 5) If cp does what you want then that would be the way to go, especially since that is what ultimately gets used underneath everything. The differences in the POSIX path definitions is that I was trying to duplicate the path text that you were using in your original script, while Hiroto was assuming a regular folder alias and stripping off the trailing path delimiter. The Finder and *System Events* use colons (:) as path delimiters, while the shell utilities use slaxhes (/) - see http://www.satimage.fr/software/en/smile/externalcodes/filepaths.html for more information about using POSIX and Finder/AppleScript path specifications.

Hiroto's cp handler will continue to copy in the event of an error, although if there are errors in the paths or the cp results, you would still get an AppleScript error dialog (this can also be trapped by a try statement).

Jan 28, 2010 3:36 PM in response to red_menace

cop2drop("Macintosh HD:Users:home:test", "zome's Public Folder:") -- FINDER version w/o Drop Box:

on cop2drop(sourceFolder, destFolder)
with timeout of 36000 seconds
tell application "Finder"
duplicate folder sourceFolder to folder destFolder
end tell
end timeout
end cop2drop


1 & 2) {...} your script works for me if the destination is not a drop box (e.g. the Public folder)
- not sure what error -8068 is, but -8086 is "destination permissions error", which would
most likely be a drop box error.


No it's really error -8068. I've searched on the internet for hours but couldn't find information
about it. Now I've modified this script a bit, because I prefer the form where only one parameter
is passed to the subroutine:

cop2drop("test") -- FINDER version w/o Drop Box MODIFIED

on cop2drop(currentFolder)
set sourceFolder to "Macintosh HD:Users:home:" & currentFolder
set destFolder to "zome's Public Folder:Drop Box:" & currentFolder & ":"
with timeout of 36000 seconds
tell application "Finder"
duplicate folder sourceFolder to folder destFolder
end tell
end timeout
end cop2drop


Actually it is the same script, isn't it? BUT now I get another error:
"Finder got an error: The operation can’t be completed." number -43

How can this be?
I assume this script also works fine for you and copies into zome's Public Folder?
How can I find out how to get it to work...?
The Sharing and Permissions settings of zome's Public Folder are:
zome (Me): Read & Write
staff: Read only
everyone: Read only

I think this is default/standard. What are your settings?

BTW Does duplicate copy all contents? ("extended attributes, resource forks, and ACLs")

I would prefer to use the above, but in case there is no way to get it to work...:

4 & 5) cp - The differences in the POSIX path definitions
is that I was trying to duplicate the path text that you were using in your original script,
while Hiroto was assuming a regular folder alias and stripping off the trailing path delimiter.


I've modified it also a bit and it works:

cop2drop("test") -- CP MODIFIED

on cop2drop(currentFolder)
set sourceFolder to quoted form of POSIX path of ("Macintosh HD:Users:home:" & currentFolder & ":")
set destFolder to quoted form of POSIX path of ("zome's Public Folder:Drop Box:" & currentFolder & ":")
tell application "System Events" to try -- make sure currentFolder exists, skipping the error if it does
make new folder at end of folder "zome's Public Folder:Drop Box:" with properties {name:currentFolder}
end try
do shell script "cp -pR " & sourceFolder & space & destFolder
end cop2drop


Because the destination Folder is always empty, it's never required to try before making the folder.
So I tried to remove the "tell application..." and the "end try..." lines, but the AppleScript Editor
didn't accept it - displaying the error:

"Syntax Error - Expected end of line, etc. but found “"”."


Why? It makes no sense...

BTW Does "*cp -pR*" copy all contents? ("extended attributes, resource forks, and ACLs")

Thanks again for your help!

Jan 28, 2010 4:31 PM in response to coxorange

I don't know what the -8068 error is either, although it looks like you are trying to copy into a folder that isn't there. If you are copying the folder, you just need to use the parent destination - don't include the source folder name, since it won't be there:
set destFolder to "zome's Public Folder:Drop Box:"

The Finder's duplicate command keeps all of the attributes, although if there are any inherited ACLs on the destination those would be applied.

The modified cp script has a similar problem with the destination path, although I'm not sure what would be giving you that particular error unless you left in the make new folder statement, which will fail since it uses *System Events* terminology.
cop2drop("test") -- CP MODIFIED
on cop2drop(currentFolder)
set sourceFolder to quoted form of POSIX path of ("Macintosh HD:Users:home:" & currentFolder)
set destFolder to quoted form of POSIX path of ("zome's Public Folder:Drop Box")
do shell script "cp -pR " & sourceFolder & space & destFolder
end cop2drop

From the man page:
The -p parameter causes cp to preserve the following attributes of each source file in the copy: modification time, access time, file flags, file mode, user ID, and group ID, as allowed by permissions. Access Control Lists (ACLs) and Extended Attributes (EAs), including resource forks, will also be preserved.

ALthough we took the (really) long way around, I think all you need is the modified cp handler.

Jan 29, 2010 5:34 AM in response to coxorange

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)

Jan 30, 2010 5:49 PM in response to Hiroto

Lots of thanks, red_menace and Hiroto for making important things clear.

1. SYSTEM EVENTS version => NOT WORKING => I will not use this :

cop2drop("Macintosh HD:Users:home:test")

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


I still got these errors:

==> error number -1728 from «class cfol» "zome's Public Folder:Drop Box:"
Result:
error "System Events got an error: Can’t set folder \"zome's Public Folder:Drop Box:\" to folder \"zome's Public Folder:Drop Box:\"." number -10006 from folder "zome's Public Folder:Drop Box:"


But don't bother... The following...

2. FINDER version WORKS perfectly now! 🙂 :

Here is the solution, at least with some preparation in zome's (and now also yome's) Public Folder:
1. I made a folder called "dubbed" in zome's (and yome's) Public Folder
2. I made it a shared folder
3. I've changed the User rights of "Everyone" from "Read Only" to "Read & Write"

I mounted zome's iMac and yome's iMac manually by clicking through the Finder.
(Is there a script command for "mounting-if-not-yet-mounted"? Would be easier.)

The script is nearly complete now I guess:

property machinesList : {"zome", "yome"}
on run
repeat with xome in machinesList
dub2dubbed("test", xome)
-- dub2dubbed("Pictures", xome)
-- dub2dubbed("Desktop", xome)
-- dub2dubbed("Documents", xome)
-- dub2dubbed("Sites", xome)
beep
beep
delay 5
end repeat
end run

on dub2dubbed(currentFolder, currentMachine)
set sourceFolder to "Macintosh HD:Users:home:" & currentFolder
set destinationFolder to currentMachine & "'s Public Folder:dubbed:"
with timeout of 36000 seconds
tell application "Finder"
duplicate folder sourceFolder to folder destinationFolder -- with replacing
end tell
end timeout
beep
end dub2dubbed


It seems to work well. Is anything wrong with it I might have missed?

*BUT ONE OTHER THING:*
After the copying (with progress bars being displayed! 🙂 ) zome/yome has no rights
to accecc the arrived folders like e.g. "Pictures". (red minus on the folder icon)
For these folders I had to set up zome/yome's rights manually. Cumbersome...
Could the script do this for arriving folders?
Or at the end in one turn for all subfolders of "dubbed"?

Thanks again -- you both were such a great help, I really appreciate it!

Jan 30, 2010 6:15 PM in response to coxorange

*Standard Additions* has a mount volume command that can be used to mount your external volume. For the permissions, you could change them manually on the copied items, but it might be easier to just set an ACL on the containing folder (see the chmod manual page), for example, the user's *Drop Box* typically has entries such as:
0: user: whoever allow list,add file,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr, writeextattr,readsecurity,writesecurity,chown,file_inherit,directoryinherit

The inherited entries will allow the owner of the folder to read, write, and change permissions on the items as needed - a group could also be added. Access Control List entries will need something more than the *Get Info* dialog though, such as the Terminal or Sandbox (Sandbox hasn't been updated to the new scripting frameworks in Snow Leopard so there are a a few interface errors, but it appears to still function).

Feb 2, 2010 7:32 AM in response to red_menace

Thanks for the information!

Regarding the problem "... *you don't have permission to see the contents*..." of the copied folders, I added another step to the preparations:

1. I made a folder called "dubbed" in zome's (and yome's) Public Folder
2. I made it a shared folder
3. I've changed the User rights of "Everyone" from "Read Only" to "Read & Write"
4. (NEW) I've changed the folder permissions via Terminal:
chmod +a "$USER allow list,addfile,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr, writeextattr,readsecurity,writesecurity,chown,file_inherit,directoryinherit" ~/Public/dubbed

Regarding the mounting problem, here is the updated script:

property machinesList : {"zome", "yome"}
on run
tell application "Finder"
try
-- mount volume ("afp://192.168.0.3:548/zome's Public Folder") as user name "zome" with password "sillypw" -- brings dialog box
-- mount volume ("afp://192.168.0.4:548/yome's Public Folder") as user name "yome" with password "sillypw" -- brings dialog box
open location "afp://zome:sillypw@192.168.0.3:548/zome's Public Folder/"
open location "afp://yome:sillypw@192.168.0.4:548/yome's Public Folder/"
end try
end tell
repeat with xome in machinesList
dub2dubbed("Pictures", xome)
-- more sources follow...
delay 2
end repeat
end run
on dub2dubbed(currentFolder, currentMachine)
set sourceFolder to "Macintosh HD:Users:home:" & currentFolder
set destinationFolder to currentMachine & "'s Public Folder:dubbed:"
with timeout of 36000 seconds
tell application "Finder"
activate "Finder"
duplicate folder sourceFolder to folder destinationFolder
end tell
end timeout
repeat 5 times
beep
end repeat
end dub2dubbed


Regarding the mounting problem:
1. The deactivated "-- mount volume..." version works, but brings the dialog box to confirm! Why??
2. The open location version works FROM TIME TO TIME, BUT NOT RELIABLY - curious, isn't it? What could cause this problem?

3 questions regarding duplicate script

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.