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)
Something like this may do the trick, but of course be careful with it!
find . -name ".svn" -exec rm -rf {} \;
Try something like this first to do a dry run:
find . -name ".*" -exec echo {} \;
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").
Is this Unix or Windows? On Unix, an easy solution is
find . -name '.svn' -type d | xargs rm -rf
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
find . -name '.svn' -type d | xargs echo
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.
Since you're looking for a DOS solution, last week's post was almost identical and the consensus was:
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, apparently TortoiseSVN also gives you the option to export a working directory without the .svn/_svn directories.
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:
xcopy /S/Q/EXCLUDE:svn.excludelist [path_from] [path_to\]
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:
.svn
.svn\
\.svn\
.obj
.o
.lib
\src\
And so on...