+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, batch file to extract data from robocopy log in Coding and Web Development; With nothing better to do on a sunny saturday afternoon i am trying to knock a script that will examine ...
  1. #1
    projector1's Avatar
    Join Date
    Nov 2005
    Posts
    460
    Thank Post
    70
    Thanked 1 Time in 1 Post
    Rep Power
    18

    batch file to extract data from robocopy log

    With nothing better to do on a sunny saturday afternoon i am trying to knock a script that will examine a robocopy text file (used for mirroring data) and dump the summary into a seperate log file which i will use blat to email me.

    this is what i have knocked up so far

    REM this batch file will sync srv11 H:\common data to srv5 H:\common2
    Set logfile=E:\logs\commonMIR1.log
    Set logfile2=E:\logs\commonMIR2.txt

    Echo Started %date%,%time% >>%logfile%
    Echo ----------------------------------- >>%logfile%
    Echo mirroring common directory on SRV11 to SRV5 common2 >>%logfile%
    Echo. >>%logfile%
    robocopy "x:\COMMON" "y:\COMMON2" /MIR /ZB /W:0 /A /LOG:E:\logs\COMMONmir2.TXT
    Echo ----------------------------------- >>%logfile%
    Echo Finished %date%,%time% >>%logfile%
    Echo ----------------------------------- >>%logfile%
    Echo RESULT OF ROBOCOPY COMMON FOLDER MIRROR SCRIPT >>%logfile%
    type %logfile2% >>%logfile%

    it works well however the whole contents of the robocopy log appear in the commonMIR1.log.
    thanks

  2. #2


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,750
    Thank Post
    221
    Thanked 2,626 Times in 1,936 Posts
    Rep Power
    778
    You could use PowerShell to read the last 14 lines of your log file...

    Code:
    Get-Content .\CommonMIR1.log | Select-Object -Last 14
    ... and send it via e-mail with the Send-MailMessage cmdlet?

  3. #3
    projector1's Avatar
    Join Date
    Nov 2005
    Posts
    460
    Thank Post
    70
    Thanked 1 Time in 1 Post
    Rep Power
    18
    I have not used powershell before, the server i am working on is a 2003 r2 machine. It may be a good time to start, thanks

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 4
    Last Post: 6th November 2008, 01:42 PM
  2. Extracting data from an MIS
    By MikeBostock in forum MIS Systems
    Replies: 76
    Last Post: 27th February 2008, 09:18 PM
  3. batch file to shutdown PCs
    By macca in forum Windows
    Replies: 5
    Last Post: 3rd May 2007, 09:20 AM
  4. need to extract text from a string in excel
    By projector1 in forum How do you do....it?
    Replies: 7
    Last Post: 14th February 2007, 01:41 PM
  5. prezzie batch file to collect dps logs
    By russdev in forum ICT KS3 SATS Tests
    Replies: 4
    Last Post: 16th May 2006, 12:16 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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