Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to silently delete files with a bat file

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).

like image 422
Deb Avatar asked Nov 23 '13 05:11

Deb


People also ask

What is del * * In CMD?

In computing, del (or erase ) is a command in command-line interpreters (shells) such as COMMAND.COM , cmd.exe , 4DOS, NDOS, 4OS2, 4NT and Windows PowerShell. It is used to delete one or more files or directories from a file system. del / erase.


1 Answers

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.

like image 67
jammykam Avatar answered Oct 25 '22 20:10

jammykam