1

Is it possible to analyse the log text file outputted from RoboCopy and extract the lines which are defined as "New Dir" and "Extra Dir"?

I would like the line from the log contain all the details returned regarding this "New Dir" or "Extra Dir"

The reason for completing this task is to understand how two folder structures have change over time. One version has been kept internally at the parent company, the second has been used by a consultancy.

For your information I am using Windows 7.

1 Answer 1

1

Use the following PowerShell string:

Get-ChildItem C:\robocopy-log.txt | Select-String -Pattern '(New Dir)|(Extra Dir)'


To filter out the filename and line numbers use:

Get-ChildItem C:\robocopy-log.txt | Select-String -Pattern '(New Dir)|(Extra Dir)' | ForEach-Object {$_.Line}

9
  • The code appears to run and returns immediately back to the original drive letter H:\>? Do i need some extra code to write the output to a separate text file?
    – RobN
    Commented Oct 25, 2013 at 14:21
  • @BobJim Yes. Just redirect the output to file like so: Get-ChildItem C:\robocopy-log.txt | Select-String -Pattern '(New Dir)|(Extra Dir)' > results.txt
    – Josh
    Commented Oct 25, 2013 at 14:38
  • I had been trying to use '| Get-Process | Out-File C:\results.txt.' My method appears to be far more complicated. Using your method, it does produce a text file but it's blank???
    – RobN
    Commented Oct 25, 2013 at 15:13
  • 1
    Using the code I posted and a sample text file I'm able to filter out the appropriate lines. Have you tried running the command in the PowerShell command prompt to see what results you get?
    – Josh
    Commented Oct 28, 2013 at 14:16
  • 1
    Try Get-ChildItem C:\robocopy-log.txt | Select-String -Pattern '(New Dir)|(Extra Dir)' | ForEach-Object {$_.Line} to filter out the filename and line numbers.
    – Josh
    Commented Oct 29, 2013 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .