English 中文(简体)
How can I make robocopy silent in the command line except for progress?
原标题:

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?

最佳回答

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.
问题回答

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

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.

In PowerShell, I like to use:

robocopy src dest | Out-Null

It avoids having to remember all the command line switches.

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 "^$"

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

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

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_backupEnvBackup

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

robocopy /mir /B /r:1 /nfl /ndl /njh /njs /nc /ns /np c:Quickbooks_Backup c:offsite_backupQuickbooks_Backup




相关问题
Backing up my database is taking too long

On a windows mobile unit, the software I m working on relies on a sdf file as it s database. The platform that the software is targeted towards is "less than optimal" and hard resets every once and a ...

Cognos LAE Backup Automation (Batch File?)

Within Cognos 7.4 security.. one would create an LAE file to export all their users... directions here... http://www.cognos-install.co.uk/articles/backups/access_manager_export_to_lae.asp Now you ...

backup SQL Server 2005 database without data

I have one stored procedure to backup the database. It will backup metadata as well as data. Is there any option to back up the database with out data. ie, back up only the schema (Empty tables). I ...

SQL Server 2008 Auto Backup

We want to have our test servers databases updated from our production server databases on a nightly basis to ensure we re developing on the most recent data. We, however, want to ensure that any fn, ...

mysql dump stops when a row is updated

When i try to get a dump of a mysql database, the dump stops when a row in it is updated. How can i prevent that? I already tried following options with no result: -f (forces continu even when error)...

热门标签