I need a way to recursively delete a folder and its children.
Is there a prebuilt tool for this, or do I need to write one?
DEL /S
doesn't delete directories.
DELTREE
was removed from Windows 2000+
rm -rf a directory. single command to delete directory and all of its children. shell remove direcotory and its contents. Removing Folders In CMD. remove directory windows commnad.
To remove a directory, just use the command rmdir <directory name> . Note: Any directories deleted with the rmdir command cannot be recovered. Be very careful where and how you use this command.
There is no sudo command in Windows. The nearest equivalent is "run as administrator." You can do this using the runas command with an administrator trust-level, or by right-clicking the program in the UI and choosing "run as administrator."
RMDIR or RD if you are using the classic Command Prompt (cmd.exe):
rd /s /q "path"
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
If you are using PowerShell you can use Remove-Item
(which is aliased to del
, erase
, rd
, ri
, rm
and rmdir
) and takes a -Recurse
argument that can be shorted to -r
rd -r "path"
admin:
takeown /r /f folder cacls folder /c /G "ADMINNAME":F /T rmdir /s folder
Works for anything including sys files
EDIT: I actually found the best way which also solves file path too long problem as well:
mkdir \empty robocopy /mir \empty folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With