Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

DO /S ... suppress error?

May
12,834
163
Can I suppress the error messages that occur when "DO /S" cannot traverse a directory?
Code:
p:\4sysutils\release> do f in /s /a:-d /d"c:\" * ( echo %f )
IO.SYS
MSDOS.SYS
pagefile.sys
<snip>
TCC: (Sys) Access is denied.
 "C:\$Recycle.Bin\S-1-5-21-1441759175-1591074457-3961414381-500\"

It might have been dumb, but I tried what's below and got quite surprising (buggy?) results (different each time). BTW, these (below) do eventually terminate, producing exactly as many lines of output as there are files to be processed by the DO command.
Code:
p:\4sysutils\release> 2>nul do f in /s /a:-d /d"c:\" * ( echo %f )
InternetInfo_hrww.rtf
InternetInfo_hrww.rtf
InternetInfo_hrww.rtf
InternetInfo_hrww.rtf
InternetInfo_hrww.rtf
^C
p:\4sysutils\release> 2>nul do f in /s /a:-d /d"c:\" * ( echo %f )
hpbcsiSWChooserWPFUI.resources.dll
hpbcsiSWChooserWPFUI.resources.dll
hpbcsiSWChooserWPFUI.resources.dll
hpbcsiSWChooserWPFUI.resources.dll
hpbcsiSWChooserWPFUI.resources.dll
^C
 
I answered the first question.
Code:
(do f in /s /a:-d /d"c:\" * ( echo %f )) >&> nul
But what about the odd output when using the CMD style redirection?
 

Similar threads

Back
Top