Sign in to follow this  
Followers 0
OzOne666

Filecopy statistics

1 post in this topic

#1 ·  Posted (edited)

Hello,

I'm trying get a result of a copy from a destination to a source.

But i don't know how i can get the result like: File copied $x, files skipped $x, total files $x, Error during copy $x.

I have already try like you can see in the source code, but that's not realy a good... :)

This function list in array the source path with all sub folders and compare to the destination.

If the modified date is not the same filecopy erase the file in the destination.

This is the function:

Func Backup($source,$destination,$expath,$filter)
    ;Local $desktopstatus,$mydocsstatus,$favostatusstatus
    If StringRight($source, 1) = '\' Then $source = StringTrimRight($source, 1)
    If StringRight($destination & $expath, 1) = '\' Then $destination = StringTrimRight($destination & $expath, 1)
    $x=0

    $MydoncsCounter += 0
    $aCopyList = _FileListToArrayXT444($source, $filter, 1, 2, 1, $generalexlude); return full path + subfolders + filename and .ext
    $aGetDestList = _FileListToArrayXT444($destination, $filter, 1, 2, 1, $generalexlude)return full path + subfolders + filename and .ext
    $aCopyList2 = _FileListToArrayXT444($source, $filter, 1, 0, 1, $generalexlude) ; return only all fine name with her ext. to compare to the destination
    $aGetDestList2 = _FileListToArrayXT444($destination, $filter, 1, 0, 1, $generalexlude); return only all fine name with her ext. to compare with the source
    $FilesCount = UBound($aCopyList)-1 ;list files numbers in source dir.
    If @error = 1 Then
        _FileWriteLog(@ScriptDir & "\Backuptoolserrors.log", @UserName & " - " & @ComputerName & " - Error 1 - Filelisttoarray: No path is found." & " Source = " & $source, 1)
    ElseIf @error = 2 Then
        _FileWriteLog(@ScriptDir & "\Backuptoolserrors.log", @UserName & " - " & @ComputerName & " - Error 2 - Filelisttoarray: No filter is found" & " Filter = " & $filter , 1)
    ElseIf @error = 3 Then
        _FileWriteLog(@ScriptDir & "\Backuptoolserrors.log", @UserName & " - " & @ComputerName & " - Error 3 - Filelisttoarray: $iRetFormat is invalid" , 1)
    ElseIf @error = 4 Then
        _FileWriteLog(@ScriptDir & "\Backuptoolserrors.log", @UserName & " - " & @ComputerName & " - Error 4 - Filelisttoarray: No data is found" , 1)
    EndIf
    ;MsgBox(0,"test","Source: " & $source & @CRLF & "Destination: " & $destination)

    $compare = $aCopyList2[0] - $aGetDestList2[0]

    If $compare < 0 Then
        $compare = 0
    EndIf

    $compareskipped = $FilesCount - $compare
    MsgBox(0,"TEST",$FilesCount & " /// " & $compare & " Skip" & $compareskipped)
    ProgressOn("Backup Progress", "", "0 percent","","",2)
    If IsArray($aCopyList) Then
        For $x = 1 To $aCopyList[0]
            $sDest = $destination & $expath & StringReplace($aCopyList[$x], $source, '')
            $iSize = FileGetSize($aCopyList[$x]) - FileGetSize($sDest)

            If FileGetTime($aCopyList[$x], 0, 1) <> FileGetTime($sDest, 0, 1) Then
                If $source = $desktopbcksrc Then
                    $MydoncsCounter = $FilesCount - $x
                EndIf

                $b = FileCopy($aCopyList[$x], $sDest, 9)
                MsgBox(0,"TEST X",$MydoncsCounter & @CRLF & "Calcul: " & $FilesCount & " - " & $x & @CRLF & $b)

                ProgressSet( $x,"Copy files progress: " & $x & "/" & $aCopyList[0]) ;& @CRLF & $aCopyList[$x])
                _FileWriteLog(@ScriptDir & "\Backuptoolsgood.log", @UserName & " - Backup" & $source & " file: " & $aCopyList[$x] & " |-> " & $sDest, 1)
            EndIf
        Next
        If $MydoncsCounter = -1 Then
            MsgBox(0,"Copy Status","Desktop Total File: " & $b & " - " & $FilesCount & @CRLF & "Combien Copié" & $MydoncsCounter & @CRLF & "Skipped:"  & "/" & $compareskipped)
        Else
            MsgBox(0,"Copy Status","Desktop Total File: " & $b & " - " & $FilesCount & @CRLF & "Combien Copié" & $MydoncsCounter & @CRLF & "Skipped:"  & "/" & $compareskipped)
        EndIf

        ProgressSet(100 , "Done", "Complete")
    Else
        _FileWriteLog(@ScriptDir & "\Backuptoolserrors.log", @UserName & " - " & @ComputerName & " - Error 4 - No data is found - In source: " & $source, 1)
    EndIf
EndFunc

Thank you in advance.

Have a good day.

Edited by OzOne666

Share this post


Link to post
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
Sign in to follow this  
Followers 0