“rm -rf” equivalent for Windows?

前端 未结 21 1365
一向
一向 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:32

    You can install cygwin, which has rm as well as ls etc.

    0 讨论(0)
  • 2020-11-27 09:35

    via Powershell

     Remove-Item -Recurse -Force "TestDirectory"
    

    via Command Prompt

    https://stackoverflow.com/a/35731786/439130

    0 讨论(0)
  • 2020-11-27 09:35

    Here is what you need to do...

    Create a batch file with the following line

    RMDIR /S %1

    Save your batch file as Remove.bat and put it in C:\windows

    Create the following registry key

    HKEY_CLASSES_ROOT\Directory\shell\Remove Directory (RMDIR)

    Launch regedit and update the default value HKEY_CLASSES_ROOT\Directory\shell\Remove Directory (RMDIR)\default with the following value

    "c:\windows\REMOVE.bat" "%1"

    Thats it! Now you can right click any directory and use the RMDIR function

    0 讨论(0)
  • 2020-11-27 09:36

    Try this command:

    del /s foldername
    
    0 讨论(0)
  • 2020-11-27 09:36

    rmdir /s dirname

    0 讨论(0)
  • 2020-11-27 09:36
    rm -r -fo <path>
    

    is the closest you can get in Windows PowerShell. It is the abbreviation of

    Remove-Item -Recurse -Force -Path <path>
    

    (more details).

    0 讨论(0)
提交回复
热议问题