“rm -rf” equivalent for Windows?

前端 未结 21 1446
一向
一向 2020-11-27 08:40

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 dele

21条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 09:18

    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
    

提交回复
热议问题