144

I'm using robocopy to do backups with a PowerShell script, and it's pretty awesome, except that I'd like it to only show the progress percentage while it copies and not all of the other information.

The other information clutters the command window, which I'd clean and simple so that it's easy to see the overall progress of the backup.

Is this possible?

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
AndrewL
  • 3,126
  • 5
  • 31
  • 33

9 Answers9

256

I added the following 2 parameters: /np /nfl

So together with the 5 parameters from AndyGeek's answer, which are /njh /njs /ndl /nc /ns you get the following and it's silent:

ROBOCOPY [source] [target] /NFL /NDL /NJH /NJS /nc /ns /np

/NFL : No File List - don't log file names.
/NDL : No Directory List - don't log directory names.
/NJH : No Job Header.
/NJS : No Job Summary.
/NP  : No Progress - don't display percentage copied.
/NS  : No Size - don't log file sizes.
/NC  : No Class - don't log file classes.
Simon Warta
  • 10,850
  • 5
  • 40
  • 78
R. Koene
  • 2,600
  • 2
  • 14
  • 3
  • 1
    That's good. Note that in the original question I did specify that I still wanted the progress percentage, but this works well if you don't want anything to display. – AndrewL Sep 20 '11 at 20:26
  • 3
    There's still a "100%" message displayed. – Scott Chu Mar 05 '13 at 13:58
  • 1
    @ScottChu you realise that to display 100% at the end, is not a progress bar, right? and would serve no use either. And anyhow, it does not display 100%. The answer posted makes robocopy completely silent – barlop Jul 21 '14 at 08:28
  • 14
    This still prints a single empty line which is noticeable in batch files. – wqw Nov 02 '14 at 14:37
  • 11
    `/nc /ns` is not necessary when `/nfl /ndl` is specified. – Vojtěch Dohnal Feb 06 '17 at 13:23
  • 5
    @wqw, just add a > NUL at the EOL, and the empty line is history. –  May 15 '17 at 13:41
  • 2
    @ScottChu This prints 100% when you use the /mt switch. I guess you will have to decide if you want multithreaded, or no %s shown – Loaf Aug 25 '17 at 13:20
  • I still get file sizes in the log and use `robocopy /l /mir "$super_ordner" null /l /MT:64 /r:0 /w:0 /ns /np /nc /njh /njs /bytes /unilog:$log /lev:$Level` – Timo May 11 '20 at 10:31
  • /MT is bugged. It breaks some other silent settings. The only way around this is >nul. – jim birch Apr 02 '23 at 23:30
46

I did it by using the following options:

/njh /njs /ndl /nc /ns

Note that the file name still displays, but that's fine for me.

For more information on robocopy, go to https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
AndrewL
  • 3,126
  • 5
  • 31
  • 33
33

If you want no output at all this is the most simple way:

robocopy src dest > nul

If you still need some information and only want to strip parts of the output, use the parameters from R.Koene's answer.

dss539
  • 6,804
  • 2
  • 34
  • 64
SHernandez
  • 1,060
  • 1
  • 14
  • 21
  • 7
    I test `> log:nul` under win8.1 x64, there is a empty log file. `> nul` works as expected. – Ivan Yan Apr 04 '15 at 14:03
  • 3
    The "empty" `log` file this generates isn't even truly empty. It's just saving the data to an [alternate stream](https://blogs.technet.microsoft.com/askcore/2013/03/24/alternate-data-streams-in-ntfs/) that is invisible to Explorer, but very much still present on the disk. (You can check by using the `dir /r` command to show it.) @IvanYan is correct, `> nul` is the correct command to discard the output entirely. – jmbpiano Jun 25 '16 at 02:53
22

In PowerShell, I like to use:

robocopy src dest | Out-Null

It avoids having to remember all the command line switches.

Aaron Tribou
  • 1,353
  • 1
  • 13
  • 22
  • When doing this, it immediately killed the command with no warning. I was using `/PURGE`. – Kevin Ghadyani Jan 28 '17 at 11:46
  • 2
    Out-Null should have no effect on the execution of the robocopy command. It simply redirects the output stream. https://msdn.microsoft.com/en-us/powershell/reference/4.0/microsoft.powershell.core/out-null You might try removing the Out-Null to see if the discarded output offers any clue to what's happening. – Aaron Tribou Jan 28 '17 at 15:43
3

robocopy also tends to print empty lines even if it does not do anything. I'm filtering empty lines away using command like this:

robocopy /NDL /NJH /NJS /NP /NS /NC %fromDir% %toDir% %filenames% | findstr /r /v "^$"
TarmoPikaro
  • 4,723
  • 2
  • 50
  • 62
1

A workaround, if you want it to be absolutely silent, is to redirect the output to a file (and optionally delete it later).

Robocopy src dest > output.log
del output.log
HSM
  • 91
  • 1
  • 1
  • 7
0

I'm not sure if it is correct but I used this in Gitlab and it works:

robocopy <src> <dst> *.dll *.exe *.bat /E; $LastExitCode
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
-1

The > null does not work in the quotes. It sees the > null as the batch filename.

The robocopy no output worked!!!

Here is the new batch file:

robocopy /mir /B /r:1 /nfl /ndl /njh /njs /nc /ns /np c:\EnvBackup c:\offsite_backup\EnvBackup

robocopy /mir /B /r:1 /nfl /ndl /njh /njs /nc /ns /np c:\shares c:\offsite_backup\shares

robocopy /mir /B /r:1 /nfl /ndl /njh /njs /nc /ns /np c:\Quickbooks_Backup c:\offsite_backup\Quickbooks_Backup
The Hungry Dictator
  • 3,444
  • 5
  • 37
  • 53
Jason L
  • 94
  • 2
  • 5
-4

There's no need to redirect to a file and delete it later. Try:

Robocopy src dest > null 
user247702
  • 23,641
  • 15
  • 110
  • 157
areB
  • 1
  • 3
    This creates a file `null` and writes the log to it. It quiets it in the command line at the cost of storage drive writes. – Kevin Ghadyani Jan 28 '17 at 11:44
  • 3
    I think OP meant to type `nul` (not `null`), which is a special reserved file name on Windows that is similar to `/dev/null` on Linux. Still, this doesn't answer OP's question. – Cameron Tacklind Feb 09 '22 at 00:29