Results 1 to 3 of 3

Thread: [RESOLVED] Parsing RoboCopy Log With Strings

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Resolved [RESOLVED] Parsing RoboCopy Log With Strings

    I'm trying to parse a RoboCopy log to get the possible failures. An example of the end of the log is here:

    Code:
         Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :         1         1        
    0         0         0         0
       Files :       106       106         0         0         0         0
       Bytes :  481.53 m  481.53 m 0         0         0         0
       Times :   0:00:11   0:00:10                       0:00:00   0:00:00
    I've managed to pull the lines of data I need:

    VB.NET Code:
    1. Dim file_lines As String() = File.ReadAllLines("C:\log.txt")
    2.         For Each line As String In file_lines
    3.             If line.Length >= 10 Then
    4.                 Select Case True
    5.                     Case line.Substring(0, 10).ToLower.Contains("files :")
    6.                         Dim new_line As String = line.ToLower.Replace("files :", "")
    7.                         Me.txtFiles.Text = new_line.Trim
    8.                     Case line.Substring(0, 10).ToLower.Contains("dirs :")
    9.                         Dim new_line As String = line.ToLower.Replace("dirs :", "")
    10.                         Me.txtDirectories.Text = new_line.Trim
    11.                     Case line.Substring(0, 10).ToLower.Contains("bytes :")
    12.                         Dim new_line As String = line.ToLower.Replace("bytes :", "")
    13.                         Me.txtBytes.Text = new_line.Trim
    14.                 End Select
    15.             End If
    16.         Next

    Which returns the data like this:

    Name:  mDQOB.png
Views: 1401
Size:  20.0 KB

    Which looks good. I know the index of columns I need to grab, but I don't how to pull that data from this string. Any ideas on how to get each column as needed? For example, if I only needed to grab column index 4, what would be the best way of doing it?

    Thanks
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Parsing RoboCopy Log With Strings

    Dim files() As String = Split(Me.txtFiles.Text, " ")

    This assigns the values individually to an array, so the 4th column value would be ... files(3)

  3. #3

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Parsing RoboCopy Log With Strings

    Quote Originally Posted by dunfiddlin View Post
    Dim files() As String = Split(Me.txtFiles.Text, " ")

    This assigns the values individually to an array, so the 4th column value would be ... files(3)
    Just to clarify, I want the 5th item, not 4th. Which is why I said the index 4. But that's mostly irrelevant.

    I had to play around with this a bit more, but was able to get the desired results. Thanks
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width