# encoding: ascii
# api: powershell
# title: Robocopy Summary
# description: Quickly pull files copied and size from robocopy log summary
# version: 0.1
# type: function
# author: Steele Stenger
# license: CC0
# x-poshcode-id: 4686
# x-archived: 2013-12-13T12:49:56
# x-published: 2013-12-10T17:34:00
#
#
Function GetTOCStats {
    $TOCsummary = get-content -path "$env:USERPROFILE\desktop\testReport.log"
    [array]::Reverse($TOCsummary)
    [int] $i = "0"
    [string] $strTotal =  "Total"
    [string] $strCopied = "Copied"
    $TOCsummary | % {
        if (Select-String -Pattern "Total    Copied   Skipped  Mismatch    FAILED    Extras" -InputObject $_ -Quiet) {
            $start = $TOCsummary[$i].IndexOf($strTotal) + $strTotal.length
            $end = $TOCsummary[$i].IndexOf($strCopied) + $strCopied.length
            $copiedColumnwidth = ($end - $start)
            $TOCfileCount = $TOCsummary[($i-2)].substring($start,$copiedcolumnwidth).trim()
            $TOCsize = $TOCsummary[($i-3)].substring($start,$copiedcolumnwidth).trim()
            write-host "# of files: $TOCfileCount"
            write-host "Copy size: $TOCsize"
            }
            $i++
    }
}

GetTOCStats
