rf equivalent for Windows?

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+


RMDIR or RD if you are using the classic Command Prompt (cmd.exe):

rd /s /q "path"

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

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

  • 链接地址: http://www.djcxy.com/p/2694.html

    上一篇: 如何用另一个回购库替换一个git子模块?

    下一篇: rf等效于Windows?