Remove percentages from robocopy log
/njh
and /njs
have nothing to do with the percentage information. You need to suppress progress output by adding the option /np
to your robocopy
commandline.
From the documentation:
/np
Specifies that the progress of the copying operation (the number of files or directories copied so far) will not be displayed.
Edit: After taking a look at your actual commandline it looks like /np
is not compatible with /mt
. Adding the latter parameter makes robocopy
display progress output even if /np
is present. If you don't require running multi-threaded I'd remove that parameter (add /ndl
to prevent directories from appearing in the output).
I would also recommend using splatting instead of putting the parameter list into a single string:
$params = $src, $dest, ('/LOG:"{0}"' -f $logpath), '/L', '/NP', '/NC', '/BYTES', '/NJH', '/NJS', '/NDL', '/E', '/MOVE', '/XC', '/XN', '/XO', '/XD', $excludedFoldersList& robocopy @params
If for some reason you must use multi-threading you should be able to remove progress information from the log after completion like this:
(Get-Content $logpath) | Where-Object { $_ -notmatch '^\s*\d{1,3}%\s*$'} | Set-Content $logpath