Jump to content

FTP Synchronize


wehr
 Share

Recommended Posts

Hi,

a few years ago i compiled a script that synchronizes 2 folders. I.e. Search both directories for new/changed/deleted files and equalizes both of them every X secs. Now i'd like to readjust this script to make is synchronize a folder on my computer and a folder on my ftp server. But so far i have no idea how to work with the ftp files. Hope u got some hints.

My Script so far:

$Ausgangspfad = "C:\OPTIMAWIN\daten\" ;Directory 1
$Zielpfad = "C:\OPTIMAWIN\" ;Directory 2


AdlibRegister ( "_synch", 5000)



While 2
    sleep (10)
WEnd

Func _synch()
    AdlibUnRegister()
    $search = FileFindFirstFile($Ausgangspfad&"*.*")

    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop

        if StringInStr($file, ".") > 0 Then
            if Not FileExists ( $Zielpfad&$file) Then
                TrayTip("Synch","File Not Found"&@CRLF&$file, 10, 4)
                $File_ergebnis = Filecopy ( $Ausgangspfad&$file, $Zielpfad&$file)
                If $File_ergebnis = 1 Then
                    TrayTip("Synch File Copy","OK"&@CRLF&$file, 10, 4)
                Else
                    TrayTip("Synch File Copy","Error"&@CRLF&$file, 10, 2)
                EndIf
            Else
                if FileGetSize ($Ausgangspfad&$file) <> FileGetSize ($Zielpfad&$file) Then
                    TrayTip("Synch","File Size Change"&@CRLF&$file, 10, 4)
                    $File_ergebnis = Filecopy ( $Ausgangspfad&$file, $Zielpfad&$file,1)
                    If $File_ergebnis = 1 Then
                        TrayTip("Synch File Copy","OK"&@CRLF&$file, 10, 4)
                    Else
                        TrayTip("Synch File Copy","Error"&@CRLF&$file, 10, 2)
                    EndIf
                Else
                EndIf
            EndIf
        Else
            if Not FileExists ( $Zielpfad&$file) Then
                TrayTip("Synch","Dir Not Found"&@CRLF&$file, 10, 4)
                $Dir_ergebnis = DirCopy ( $Ausgangspfad&$file, $Zielpfad&$file,1)
                If $Dir_ergebnis = 1 Then
                    TrayTip("Synch Dir Copy","OK"&@CRLF&$file, 10, 4)
                Else
                    TrayTip("Synch Dir Copy","Error"&@CRLF&$file, 10, 2)
                EndIf

            Else
                if DirGetSize ($Ausgangspfad&$file) <> DirGetSize ($Zielpfad&$file) Then
                    TrayTip("Synch","Dir Size Change"&@CRLF&$file, 10, 4)
                    $Dir_ergebnis = DirCopy ( $Ausgangspfad&$file, $Zielpfad&$file,1)
                    If $Dir_ergebnis = 1 Then
                        TrayTip("Synch Dir Copy","OK"&@CRLF&$file, 10, 4)
                    Else
                        TrayTip("Synch Dir Copy","Error"&@CRLF&$file, 10, 2)
                    EndIf

                Else
                EndIf
            EndIf

        EndIf
    WEnd
    FileClose($search)
    AdlibRegister ( "_synch", 60000)
EndFunc
Link to comment
Share on other sites

I found a solution using Cyberkiko | FTPsync a GUI-less utility that does exactly what my script did, but with FTP support. Thanks if u tried helping.

WOW!! I just sat down to start to write some software like this, and 10 minutes of playing with FTPSync later, I'm practically finished. Fantastic tool, and thanks for posting your solution to your own question!

D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...