34
del /s .jpg

deletes all .jpgs .. but the problem is: it shows, in cmd when executed =>
C:\blabla..\this.jpg is deleted..

I want to turn this off. Such that user will not know what is happening (i.e, what files are being deleted).

live-love
  • 48,840
  • 22
  • 240
  • 204
Deb
  • 5,163
  • 7
  • 30
  • 45

3 Answers3

67

Turn echo off to suppress showing the command being run, and redirect output to null as @Sico suggested.

@echo off
del /s *.jpg  >nul 2>&1

You should see nothing displayed when the bat file is run.

jammykam
  • 16,940
  • 2
  • 36
  • 71
32

In jammykam's answer, he uses >nul 2>&1. What this does is redirect both standard output and standard error to the null device. However, hiding the standard error is not best practise and should only be done if necessary.

@echo off
del /s *.jpg 1>nul

In this example, 1>nul only hides the standard output, but standard error will still show. If del fails to delete some files, you will be informed.

Read more about redirection

BoffinBrain
  • 6,337
  • 6
  • 33
  • 59
-3

Try putting this at the top of your batch script: @echo off

user3020494
  • 712
  • 6
  • 9
  • Why was I down voted? same answer is given by another person later than me but is upvoted :) – user3020494 Nov 23 '13 at 06:15
  • 1
    Well, I did not down voted you. But @echo off really do not do anything in this case. and Thanks for first reply. :) – Deb Nov 23 '13 at 06:56
  • 6
    The other answer is also about redirecting output to null. `@echo off` does hide the call, but not the output. – GolezTrol Nov 23 '13 at 08:15
  • 4
    Yes, >nul is the answer of my question, I already used @echo off in my program. But that does not hide the output. (However I should have mentioned that.) It only hides the command. – Deb Nov 23 '13 at 09:14