Help with Backup Script

I am a new at AppleScripting and would appreciate any help I can get with the following script.

Context: I have 7 photographers shooting digital in my studio. Each day they create a folder on the desktop with the days raw captures and processed final shots. I need these folders to get backed up automatically on a nightly basis. I have the script below making a folder on the backup volume named with the users name and current date. This part of it works.

Problem: I get an error each time the script runs. It does not complete the copying of the contents of the desktop folder. Everything else seems to work fine. Anyone have any ideas?

Here is the script as it is now:
set namevar to “Photo2”
– sets the namevar to the computer users name
try
mount volume “afp://username:password@192.168.22.8/HiRes/”
– mounts HiRes volume
on error errText number errNum
display dialog “An Error Occured mounting server” & “Error Number” & errNum & “”
end try
– if there was a problem, it tells you

tell application “Finder”
make new folder at folder “HiRes:CaptureBackup:” with properties {name:“TEMP”}
–the finder makes a new temp folder

set file_location to "HiRes:CaptureBackup:"
-- sets the file path

set folder_name to namevar & (do shell script "date +%m_%d_%y")
-- sets the variable folder_name to namevar and the date

set file_path to ((file_location as string) & folder_name & ":")
-- sets the file path to the file location and the folder name that was set above

set file_alias to ("HiRes:CaptureBackup:TEMP") as alias
-- sets the path to the server volume

tell application "Finder"
	set name of file_alias to folder_name
	-- sets the folder alias (temp folder path) variable to the folder name
end tell
move folders of folder "Desktop" of folder namevar of folder "Users" of startup disk to file_alias
-- moves only folders in the desktop folder to the server

end tell

Also, does anyone know how to get the current users name automatically so I do not have to hard code it? And is there an easy way to make a log file of what has been backed up successfully?

Thanks,

OK, well, I basically rewrote the script…sorry :? It cleans up a few things such as the creation/naming of the backup folder. I think the only actual problem with your script may be the “move” line. You may want to try replacing it with

move (every item of folder "Desktop" of folder namevar of folder "Users" of startup disk whose kind is "Folder") to file_alias

I think that will make yours work for you since it looks like getting “folders of the desktop” also returns things like your startup disk (whcih I guess is kind of a folder, but it’s “kind” is “disk” so the above line should correct it). Also, as you can see from my “redone” script below, you can get the current user name by querying System Events like so:

tell application "System Events" to set userName to name of current user

Here’s what I came up with. You can either use this or edit your script to include the above noted fixes.


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Hope this helps.