Copying updated files at login

We have a customer who logs into a Samba network and wants updated files from his laptop to be copied to the network volume.

Is there a way to use AppleScript so that when he logs in it checks network connectivity and thus subsequently drive mappings and then copy across all the updated files that he’s worked on to the network?

Sure. Adjust as appropriate:

set shareName to "SMB_Disk"
set localFolder to "path:to:local:folder:"
set remoteFolder to "path:to:server:folder:"

tell application "Finder"
   -- check if the server is mounted
   if (exists volume shareName) = false then
      -- not mounted, so mount it
      open "smb://username:password@server/SMB_Disk"
   end if
   -- now copy the files
   duplicate every file of folder localFolder to folder remoteFolder with replacing
end tell

Sweet thanks for that.

But does this check if a file has been updated since the last running of the script?

Is that easy to do or would it be just easier to upload all files?

No, it duplicates all files.

The easiest way to do this is to add a property to your script that tracks the last run time and use that as a comparison to find new files:

property lastRun: date "Thursday, January 1, 2004 12:00:00 AM" -- some arbitrary date

set shareName to "SMB_Disk" 
set localFolder to "path:to:local:folder:" 
set remoteFolder to "path:to:server:folder:" 

tell application "Finder" 
   -- check if the server is mounted 
   if (exists volume shareName) = false then 
      -- not mounted, so mount it 
      open "smb://username:password@server/SMB_Disk" 
   end if 
   -- now copy the files, note the 'whose clause' to restrict the files
   duplicate (every file of folder localFolder whose modification date is greater than lastRun) to folder remoteFolder with replacing 
end tell
-- update the lastRun property
set lastRun to (get current date)

The property will automatically be saved in the script and used in subsequent runs of the script.