Reputation: 35404
Let's say we have a file or a folder named c:\temp
and we need to remove it if it exists.
What is the command to do it?
Upvotes: 1
Views: 420
Reputation: 16591
Err... why not do both? :)
rd /q /s c:\temp
del /q c:\temp
One of them will succeed if C:\temp
is either a file or a folder and the other one will fail. If both fails, it means that it couldn't be deleted or not found. You can even make it a batch file if you don't want to type both commands in all the time.
Upvotes: 2
Reputation: 35404
It is del c:\temp
. Sorry I thought it was only used for files and not applicable for folders
Upvotes: 0
Reputation:
C:\>rmdir /? Removes (deletes) a directory. RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path /S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree. /Q Quiet mode, do not ask if ok to remove a directory tree with /S
Upvotes: 2