Can I shut down echo for this “for” cycle inputed from cmd?

前端 未结 2 1827
挽巷
挽巷 2021-01-06 16:09

I was trying to use this excellent answer.

Is there a way to have ONE command line that executes the following (delete all files of size zero) without printing any o

相关标签:
2条回答
  • 2021-01-06 16:41

    @ suppresses the output for one command. So the following does what you want:

    for /r %F in (*) do @if %~zF==0 @del "%F"
    

    To show (only) the files that were deleted:

    for /r %F in (*) do @if %~zF==0 del "%F" & echo removed %F
    
    0 讨论(0)
  • 2021-01-06 17:01
    @echo off && for /r %F in (*) do if %~zF==0 del "%F" > NUL
    

    The > NUL is because I can't recall if certain situations cause del to try to output

    0 讨论(0)
提交回复
热议问题