Simple Script to copy folder to AFP

Hi everyone,

I need a simple script to copy a folder to a xserve (via AFP with a username/password). it must be done at a certain time every night.

Thanks for your time :wink:


try this, you must adjust the properties values and the source and destination paths

property theServer : "myServer"
property serverVolume : "myVolume"
property uName : "username"
property pWord : "¢¢¢¢¢"

if (serverVolume is not in (do shell script "/bin/ls /Volumes")) then
	mount volume "afp://" & uName & ":" & pWord & "@" & theServer & "/" & serverVolume
end if
set sourceFolder to quoted form of "/Users/myUser/path/to/folder"
set destinationFolder to quoted form of ("/Volumes/" & serverVolume & "/path/to/folder")
	do shell script "/usr/bin/rsync -auE " & sourceFolder & space & destinationFolder
end try

The scheduler can be an iCal event or a launchd agent

Thanks you StefanK for your help :slight_smile:

Can you eject the AFP server after the transfert ? and what about the launchd agent ?


For the launchd agent take a look at

Add this line at the end of the script to eject the shared volume

do shell script "/usr/sbin/diskutil unmount /Volumes/" & myVolume

Thanks for your fast respond :wink:

I got a error message when the volume unmount “Unmount failed for /Volumes/STUDIO/” but it’s works, the volume is unmounted …

Is the launchd works on Leopard ?

Thanks you so much


yes, launchd has been introduced in Tiger