PoshCode Archive  Artifact [87fad67552]

Artifact 87fad6755252d00d99afe94b378f5a6363ff79485690bc1d3ad2a71e6ac000fa:

  • File Robocopy-Summary.ps1 — part of check-in [b4f2b15414] at 2018-06-10 13:44:34 on branch trunk — Quickly pull files copied and size from robocopy log summary (user: Steele Stenger size: 1229)

# 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