Sorry for the litany of posts lately, but I’m getting frustrated. Following is a part of a long XCode Script:
tell application "Finder" set d to ":" set newName to "TempUser" set userName to last word of (path to current user folder as text) set startDisk to name of startup disk set userHome to home as text set destinFolder to "Macintosh HD:Users:Shared:" with timeout of 5000 seconds try duplicate userHome to destinFolder tell me to log "copying " & userHome & "to " & destinFolder duplicate userHome to destinFolder on error tell me to log "Finder action failed - trying shell" set x to destinFolder & userName try tell me to log "Erasing Finder folder" do shell script "sudo rm -r " & x password pass with administrator privileges end try tell me to log "Doing shell script copy" do shell script "sudo cp -Rp ~ /Users/Shared" password pass with administrator privileges end try tell me to log "userHome duplicated" end timeout end tell
I would love for this to take place in either the Finder or the Terminal, but I’ve had problems with both - as such - I have the try command.
When I manually copy the Users home folder to the Shared folder, there are no problems. Every time I try to use my script - which is ostensibly doing the same thing - I get the error that the folder already exists in that location. For the record - the variable “pass” is defined earlier in the script - so this is not the issue. Frequently, the shell script gives me a man page type error. What am I doing wrong? Is there a way to copy a folder outside of using duplicate? Have I put bad parameters in the shell command? I’ve even tried adding “with replacing” to the Finder script, but to no avail. I either get a privilege error, a “This file does not exist” error, or something similar. Before I beat myself to death with my 20’’ iMac, can someone offer assistance?