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 DOS only)
To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r . Directories that are removed with the rmdir command cannot be recovered, nor can directories and their contents removed with the rm -r command.
To permanently remove a directory in Linux, use either rmdir or rm command: For empty directories, use rmdir [dirname] or rm -d [dirname] For non-empty directories, use rm -r [dirname]
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.)
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