giving a password to a Finder "duplicate" command?

Hi!

I’ve run into a little weirdness while trying to write a little AppleScript to automatically backup my home directory every night, and I’d really appreciate a little help.

When I try to copy the “Library” folder (from inside my Users/username folder) to an external drive, up pops a Finder dialog asking me for my username and password. (The same thing happens if I manually drag the “Library” folder to the external drive.)

I’m surprised to see this, cuz it’s my library folder and I’m not trying to do anything that unusual with it (just copy it).

More to the point, though, could you please let me know the syntax for specifying the password and username for the Finder’s “duplicate” command? (or some other way to authenticate?)

Thanks for your help!

tell application "Finder"
	
	set hostFolder to folder "AppleScripted Lando bpus" of disk "DS160" -- where to put the created serialized bpu folders
	set userToBackup to folder "lando" of folder "Users" of disk "Lando" -- which user folder to backup
	set newFolderName to "new backup folder"
	
	set newFolder to make folder at hostFolder with properties {name:newFolderName}
	
-- below is the line that causes the password dialog to pop up
	duplicate folder "Library" of userToBackup to newFolder replacing conflicts
end tell

Hi seanrome,

I had the same exact problem. My backup script would popup an error message telling me:

“Public” was the name of the folder I was attempting to move to the remote volume.

I think there were a number of folders and / or filesin Public that I didn’t have correct privileges on, and that would prompt the authentication.

I tried to Get Info on my Public folder, and change permissions using the Finder’s “Apply to enclosed items…” option, but that didn’t seem to work. >:(

So instead I tried the utility BatChmod on the Public folder, giving myself the maximum read/write options on all files and folders and now the folder copies perfectly.

Now my concern is in ensuring that new files inherit these less restrictive priviliges, which I’m fairly certain will not happen automatically. :confused:

-Matt