Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force delete a folder in batch file?

Tags:

batch-file

How to delete a folder in a batch file forcely ?

(Note- C:\Anything is a folder)

My code is:

@echo off
del C:\Anything
pause

But it's always asking-

Do you want to delete "C:\Anything" Y/N ?

I want that C:\Anything should delete with askimg for permision to do that !

Please help to optimize my problem !!!

like image 963
Ekagra Srivastava Avatar asked Sep 16 '14 15:09

Ekagra Srivastava


People also ask

How do you force delete a folder in CMD?

Use “RMDIR /S /Q” command to force delete a folder in CMD: After entering Command Prompt window, you can type the rmdir /s /q folder path, for example, rmdir /s /q E:\test, and press Enter key. This deletes the folder named “test” in my USB drive.

How do I force delete a folder?

Use Shift + Delete to Force Delete File/Folder. You can select the target file or folder and press Shift + Delete keyboard shortcut to delete the file/folder permanently. This file deletion method won't pass the Recycle Bin.

How do you force delete a file in Windows using CMD?

How to Force Delete a File With the Windows Command Prompt. The following steps will help you force delete a file with the del command. Step 3: In the Command Prompt, type del , right-click to the paste in the folder address, and append the filename with its extension ( . html , .


1 Answers

set backupDir="D:\db_backup"

rmdir /s /q %backupDir%

here /q will eliminate that confirmation question.

like image 139
street hawk Avatar answered Oct 04 '22 01:10

street hawk