6

I can't find a way to log only the changes in the output of a robocopy execution, i.e.: those considered new file, new directory, newer file, extra file, or extra directory.

The default output as I have it now consists of a list of all directories (touched or untouched) that were considered in the copying. I want to suppress the untouched.

Help doesn't seem to show a way to do this.

AndJM
  • 265
  • What are the actual parameters you're using? Did you try with/without the verbose flag? – Seth May 02 '17 at 09:14
  • I use robocopy src dest /mir. As I understand it, /v is for showing skipped files (so, all of them), not what I am looking for. – AndJM May 02 '17 at 12:40

2 Answers2

8

If you carefully look at the documentation or robocopy /?, you will find the /NDL switch.

Specifies that directory names are not to be logged.

With this you will have no output on individual names for directories (which can be considered a type of progress marker). But "filenames" will include the path.

So for example you would get the following output:

        *EXTRA Dir        -1    C:\Temp\test\
          *EXTRA File                  0        C:\Temp\test\test.txt
100%        Newer                     72        C:\Temp\test.txt
Seth
  • 9,165
  • 1
    Great, thanks Seth. I must have misread the description for /ndl, thinking it meant something else. However, it would be nice for my purposes to also have a line in the output saying that a new directory in source was created since last mirroring. As is now, only locations to new files or as you mentioned extra items that were purged are printed. I use /LOG+:D:\backuplog.txt /TEE /NDL /NP /NS – AndJM May 02 '17 at 13:36
  • You won't be able to get that input with the /NDL switch as far as I can tell. Form what I see neither switch combination would remove "just" the "unchanged" directories that are listed. You might be able to use some regular expression (lines with just white spaces and C: in the example?) to remove those lines using an editor that either supports it or a script. – Seth May 02 '17 at 14:06
0

Using /NDL isn't the perfect solution because it will also hide any directory changes (new, changed, deleted) as well.

You can use grep to do some filtering. This isn't a perfect solution either, but it may be better than /NDL because it will list dir changes. Basically it removes rows that start with 17 whitespaces.

grep -v -E '^\s{17}' robocopy.log > changes.log
  • -v inverse match (skip the matches)
  • ^\s{17} starts with 17 whitespaces

Note: you will have to install grep (which comes with Git Bash). The {17} syntax doesn't work with findstr.

wisbucky
  • 3,076