Link to home
Start Free TrialLog in
Avatar of williamfl
williamfl

asked on

Parse Robocopy text log

Team
Looking or a way to parse Robocop log into a linear line of data so I can import into database. Did not see a way in robocapy to customize log to do so. We would like to parse the following.
 
Also if there is a way to get Robocopy to out in a linear manner so it can be imported in database. Surprised did not see in any forums.

Started : Thu Apr 17 01:17:30 2014
Source : \\servera\project1\
Dest : \\serverb\project1\
Dirs :         7         7         0         0         0         0
Files :        63        63         0         0         0         0
Bytes :   998.0 k   998.0 k         0         0         0         0
Speed :             838653 Bytes/sec.
Speed :              54.432 MegaBytes/min.
Ended : Thu Apr 17 01:17:31 2014

Need output to look like this so we can import to database. Coma delimited.

Started,Source,Dest,Dirs,files,bytes,speed,ended

Thu Apr 17 01:17:30 2014, \\servera\project1\, \\serverb\project1\,7,63,998.0, 838653, 54.432, Thu Apr 17 01:17:31 2014


Example of file. Typically we would have about 500 rows of them have 2 samples they are all the same row size. We are not displaying files or directories to keep log consistent in row size. We run each share as an individual site so it produces multiple robocpy outputs.


-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                              
-------------------------------------------------------------------------------

  Started : Thu Apr 17 01:17:30 2014

   Source : \\servera\project1\
     Dest : \\serverb\project1\

    Files : *.*
          
  Options : *.* /NC /NDL /NFL /TEE /S /E /COPYALL /DCOPY:T /PURGE /MIR /R:1 /W:1

------------------------------------------------------------------------------


------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         7         7         0         0         0         0
   Files :        63        63         0         0         0         0
   Bytes :   998.0 k   998.0 k         0         0         0         0
   Times :   0:00:01   0:00:00                       0:00:00   0:00:00


   Speed :             838653 Bytes/sec.
   Speed :              54.432 MegaBytes/min.

   Ended : Thu Apr 17 01:17:31 2014

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                              
-------------------------------------------------------------------------------

  Started : Thu Apr 17 01:17:32 2014

   Source : \\serverd\project1\
     Dest : \\servere\project1\

    Files : *.*
          
  Options : *.* /NC /NDL /NFL /TEE /S /E /COPYALL /DCOPY:T /PURGE /MIR /R:1 /W:1

------------------------------------------------------------------------------


------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         7         7         0         0         0         0
   Files :        63        63         0         0         0         0
   Bytes :   998.0 k   998.0 k         0         0         0         0
   Times :   0:00:01   0:00:01                       0:00:00   0:00:00


   Speed :             1104964 Bytes/sec.
   Speed :              57.504 MegaBytes/min.

   Ended : Thu Apr 17 01:17:33 2014
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of williamfl
williamfl

ASKER

The only things we wish we haded to list was the
Skipped   Mismatch  and Failed for Dirs and Files so we can scan for errors quicker also.  
We are looking at modify you code unless you think you can be update quickly to get the other data points.


This script is still really great. Helps when working with thousands of robocopies scripts.
I don't have access to a log with that info, at least not until next week.
If it's in the list of items, like the others, you may can just add them to the DesiredElements array (follow the same format - the entire line up until the colon (:))
Glad I could help.
Thanks for the grade! :^)