Of course I’m super new to Applescript, and I have spent several days lurking around here trying to find my way,
I need a script that will mount an ftp volume, sync with a folder on that ftp volume, unmount the volume, and close (Applescript) Oh and all this has to happen without user input and in the background.
I’m feel like I’m pretty close, but I still have a few questions, first you will see in my script that I have finder asking for the location. I don’t want that I want to put the location in the script but every time I do this I get more errors. ( I have been grabbing the folder, and dropping it into the script, as an alias) is there a better way to do this?
then the script tries to connect and mount the ftp server, if this does not succeed after 3 tries (no internet connection found) I would like the whole script to close quietly without errors.
the next part I have working pretty well, the script goes into the ftp copies the files not found on the local machine. then it is supposed to move files found on the local machine (TargetFldr) not found on the ftp (SourceFldr) to an Archive folder (on the local machine) but I get an alias error.
then I want it to unmount the Ftp volume.
FYI this is to happen on a remote kiosk while the machine is in use so I cant have any errors pop up and ruin the display.
thank you for any help…
set TargetFldr to (choose folder with prompt "Where is the target folder?")
set SourceFldr to (choose folder with prompt "Where is the source folder?")
set Archive to (choose folder with prompt "Where is the Archive folder?")
repeat 3 times
try
mount volume "ftp://user:password@server" -- if this succeeds, the internet is up.
exit repeat
on error -- no internet
delay 300 -- delay 5 minutes
end try
end repeat
tell application "Finder"
set SourceContents to list folder SourceFldr
set TargetContents to list folder TargetFldr
repeat with x in SourceContents
if x is not in TargetContents then
duplicate alias ((SourceFldr as text) & x) to TargetFldr with replacing
end if
end repeat
repeat with x in TargetContents
if x is not in SourceContents then
move alias ((TargetContents as text) & x) to Archive with replacing
end if
end repeat
end tell
eject disk "ftp://user:password@server"
Browser: Firefox 2.0.0.10
Operating System: Mac OS X (10.5)