Command line to delete matching files and directories recursively

后端 未结 6 1666
-上瘾入骨i
-上瘾入骨i 2020-12-12 14:21

How can I recursively delete all files & directories that match a certain pattern? e.g. remove all the \".svn\" directories and the files they contain?

(Sadly DO

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 14:50

    Since you're looking for a DOS solution, last week's post was almost identical and the consensus was:

    Command line tool to delete folder with a specified name recursively in Windows?

    for /d /r . %d in (.svn) do @if exist "%d" rd /s/q "%d"

    or

    for /f "usebackq" %d in ("dir .svn /ad/b/s") do rd /s/q "%d"

    Actually, SVN also gives you the option to export a working directory without the .svn/_svn directories.

    Afterthoughts, three years later: I think the reason people end up needing to recursively delete the .svn/_svn folders is because they've directly copied their local working copy to a new location in order to do a folder comparison of their modified version compared to a clean export, i.e. after something goes awry with the modified local working copy. (At least that's why I've needed it. It's definitely easier/faster to just use 'svn export' when that's possible.)

提交回复
热议问题