Help with keeping two text files in sync

I am now trying to keep an FTP folder listing and the created text file in sync. So if someone deletes a folder remotely the data file would be updated the next time it runs, by comparing the two lists.

This is the script that I have done so far… obviously it’s not doing the comparison properly.



property remoteAppleScripts : "Volumes/HD\\ Shared/Folder/AppleScripts/"
property ftpdata : "ftpdata.txt"
property ftp_login : "ftp://username:passwd@ftp.website.com:21/"
property NIXLB : "
"
--ftp listing
set ftpListing to do shell script "ftp -n " & ftp_login & " << EOF" & NIXLB & "epsv4" & NIXLB & "ls -1" & NIXLB & "bye" & NIXLB & "EOF"
get paragraphs of ftpListing

--ftp data text listing folder, username and password
set prefFile to (((remoteAppleScripts) as text) & ftpdata)
set ftpdataListing to do shell script "/usr/bin/grep -v " & quoted form of ("@@" & space) & space & prefFile

repeat with i from 1 to (count (word 1 of ftpListing))
   if (i of (word 1 of ftpListing) contains word 1 of ftpdataListing) then
       display dialog " is NOT in FTP List" buttons "Ok" default button 1 with icon caution
       exit repeat
   else
       display dialog "is IN FTP List" buttons "Ok" default button 1 with icon caution
   end if
end repeat

Thanks.

Model: PowerBook
Browser: Safari 416.13
Operating System: Mac OS X (10.4)