Duplicate items in applescript?

OK, So I would like to write a script that copies the Address Book folder from my Users:Library:Application Support folder and copies the item to my Users:Username:Backup folder. Only when I run this script it says Finder cannot handle this… am I doing anything wrong?

set shortusername to the second word of (characters (offset of "Users" in path to ¬
	preferences as string) through (length of (path to preferences as string)) of ¬
	(path to preferences as string) as string)
set AddressBackup to startup disk & "Users:" & shortusername & ":Library:Application Support:Address Book"
set BackupFolder to startup disk & "Users:" & shortusername & ":Backup"
tell application "Finder"
	duplicate AddressBackup to BackupFolder with replacing
end tell

i don’t have the whole answer for you as it is giving me problems too. however, this might be a better way to get directly to the Application Support folder:

tell application "Finder"
	set appSupportPath to (path to application support folder from user domain)
end tell

what i find strange is that i can do this just fine:


tell application "Finder"
	set appSupportPath to (path to application support folder from user domain)
	duplicate folder appSupportPath to desktop
end tell

which will dupe the entire app support folder to the desktop (or wherever), but i can’t seem to get any deeper than that without error. i think i ran into something like this a while back, something to do with access denied. don’t remember the answer. i’m sure someone here can point you in the right direction. i’ll be watching this thread.

Try removing the space from Address Book in “:Library:Application Support:Address Book”.

I agree with Muad’Dib that you can get the paths you need more easily using Standard Additions’ path to command; this should work, as long as you do have a folder named “Backup” in your Home directory:

set AddressBackup to alias (((path to application support folder from user domain) as Unicode text) & "AddressBook")
set BackupFolder to alias (((path to home folder) as Unicode text) & "Backup")
tell application "Finder" to duplicate AddressBackup to BackupFolder

heh, um…whoops. :frowning: glad you got your answer.