Hi!
I’m trying to write a little AppleScript to automatically backup my home directory every night. I’m a software developer, but I have no experience at all with AppleScript. I’m having some trouble and I’d really appreciate some words of wisdom.
I’ll attach the (short) script itself to the end of this message, but I’ve narrowed my sitch down to this:
First: when I try to copy the “Library” folder (from inside my Users/username folder), I get: “Finder got an error: An item with the same name already exists in the destination” even though the destination is a folder that I create (new & empty) on an external drive.
I’m guessing that the system is creating some special invisible file somewhere in the process. Q1: Any idea what or why?
Second: when I append “replacing conflicts” to the “duplicate” command, the system pops up a dialog while the script is running that asks me for my password. Q2: Any idea why? (I’m surprised that I’m doing anything perceived as authentication-worthy; I’m just copying my own files.) Also, how/where would I specify my username and password?
Thanks very much in advance. I thought this would be a very straightforward introduction to AppleScript but I’ve apparently started down a path littered with odd special cases. Thanks for your help!
(script follows)
- Sean Rome
srome@cinci.rr.com
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}
duplicate folder "Library" of userToBackup to newFolder
-- duplicate folder "Library" of userToBackup to newFolder replacing conflicts
end tell