Fairly new to this, so my Applescript is probably horrible.
Here is my situation. I have an FTP server outside my firewall and a file server inside my firewall. I need to create a script that moves files uploaded to the FTP server to the file server. This needs to happen fairly close to real time (currently I am executing the script every 150 seconds). What i have done so far is create a script that checks to see if the volumes are mounted (if not, it mounts them), then duplicates the files (the move command doesn’t seem to work - i assume because it’s moving from one machine to another), and finally deletes the original. As i mentioned, this executes on a timed delay.
The problem is, often the file is only partially uploaded, and the script still tries to move it, giving an error which needs to be manually cleared. Sometimes I also get permissions errors. I thought of changing the script to a folder action, but that would need to be attached to the folder on the FTP server, which can not mount the FileServer (due to the firewall restrictions).
Is there a better way to accomplish this?
on idle
try
tell application “Finder”
activate
– check to see if volume is already mounted
set DiskList to list disks --get all disks currently mounted
if DiskList contains “FTPvolume” = false then
mount volume “afp:/FTPServer” & “/FTPvolume” as user name “user” with password “password”
end if
if DiskList contains “FileVolume” = false then
mount volume “afp:/FileServer” & “/FileVolume” as user name “user” with password “password”
end if
end tell
tell application “Finder”
duplicate files in folder “FTPvolume” to “FileVolume:”
delete items in folder “FTPvolume”
end tell
return 150
end try
end idle