I’m having a weird problem getting applescript to copy a folder to a user’s Home directory. The home folder is network based but I’m having the problem locally as well. It works fine in the user that I’m scripting in but when I log in as a fresh user and run it I get the error.
‘Can’t set “Macintosh HD:private:var:automount:Network:Servers:serverpath:userhome:Library:” to <> “Preferences” of application “Finder”.’
This is the script.
tell application “Finder”
set userHome to home
set thePath to ((userHome as string) & “Library:”)
duplicate folder “Preferences” to thePath with replacing
display dialog “Preferences Copied.”
end tell
The Preferences folder I’ve placed in the Package contents but I’ve tried it with it sitting in a folder. I’ve also tried setting permissions differently on the Prefs folder but that doesn’t seem to matter. What’s even stranger is after making a couple changes to the file and resaving (logged in as the new user) it eventually works. Any ideas would be GREATLY appreciated.
I figured out the problem but I’m still stuck. I’m trying to copy a folder that I’ve put in the package Contents of the file. How would I do that? What would the proper path be? Thanks.
Does this work? It might need to be tweaked based on the hierarchy of the package.
set me_ to path to me as text
set myPrefs to (me_ & "Contents:Preferences:")
tell application "Finder"
set userHome to home as text
set thePath to (userHome & "Library:")
try
duplicate folder myPrefs to thePath with replacing
display dialog "Preferences Copied."
on error e
display dialog e buttons {"OK"} default button 1 with icon 0
end try
end tell
Ok, I believe this is a network home issue. It works fine when logged in as a local user. I think it’s choking on the long network path. Somehow the path isn’t correct.
Man I’m so confused. It WILL copy a folder from the desktop to a network home but it won’t copy it from the file contents unless I’m in as a local user.
Ha, it works if I move the app to the shared folder. Thanks for your help.