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)
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)
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?
or
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.)
Something like this may do the trick, but of course be careful with it!
Try something like this first to do a dry run:
Note that the empty braces get filled in with the file names and the escaped semicolon ends the command that is executed (starting after the "-exec").
On *nix or Cygwin:
Is this Unix or Windows? On Unix, an easy solution is
This searches recursively for all directories (-type d) in the hierarchy starting at "." (current directory), and finds those whose name is '.svn'; the list of the found directories is then fed to rm -rf for removal.
If you want to try it out, try
This should provide you with a list of all the directories which would be recursively deleted.
If your files are in subversion, then doing an export from the repository will give you a directory tree with the .svn files and any other cruft removed.
If you want to copy it without exporting and eliminating the .svn from the projects, you shold use the /EXCLUDE option from XCOPY.
Like this:
Observe the "\" (backslash) on the [path_to]. It determines that it's an output directory, so, xcopy will not question if it's a file or a directory.
The svn.excludelist is a text file containing the patterns to ignore on copy separated by line.
For Example:
And so on...