Returning Status of File Transfer

I’m brand new to Applescript and this is my first script so I’m sure there are tons of improvements that can be made.

What I need to do is mount a volume and transfer all the files from a folder to it and then disconnect the volume. Then repeat at a different location. I also want it to continue to the next location if there is an error connecting to a location. Then, at the end, display all of the successes and failures. So far, everything works, but I am having trouble with displaying all successes and failures. How I have it set up now, it will pop up a different box for each failure and not show any successes. Any suggestions would be greatly appreciated.

Here is what I have so far (this is a small piece because it repeats for each location)



Set Error1 to "0"
tell application "Finder"
	
	try
		mount volume "smb://username:password@IPAddress/Folder/Path"
		
		delay 1
		set filestomove to items in folder "local:folder:location"
		move filestomove to "Path" with replacing
		
		delay 1
		eject disk "Path"
		
	on error
		set Error1 to "ServerName Failed"
		
	end try

if Error1 is not "0" then display dialog " " & Error1

Couldn’t you set two variables for successes and failures with an initial value of 0? At the end of every transfer, increment the value by one in the corresponding if/else statement.

I think how I’m going to handle the dialog box is to set variables for each server location to have a value of “Success” by default. Then, if it fails during the Try statement, it will set the corresponding variable to “Failure” At the very end of the script, I’m displaying a dialog box with all the variables values, so I can see both the success and failures.

So it looks like:


Set Error1 to "Servername Success"
tell application "Finder"
    
    try
        mount volume "smb://username:password@IPAddress/Folder/Path"
        
        delay 1
        set filestomove to items in folder "local:folder:location"
        move filestomove to "Path" with replacing
        
        delay 1
        eject disk "Path"
        
    on error
        set Error1 to "ServerName Failed"
        
    end try

display dialog " " & Error1

on a side note, I was just informed that they want to transfer the files from a network drive instead of a local folder. How would the path need to change for

set filestomove to items in folder "local:folder:location"