views:

64

answers:

2

I need to recursively remove unnecessary files from a svn repository and i have the following batch file to do this:

@echo on
del /s ~*.*
del /s *.~*
del /s Thumbs.db

However, this is also deleting the entries under the .svn/ subfolders. Is there any way to prevent this commands from being executed under the .svn/ folders so that it doesn't mess things up?

Thanks in advance!

EDIT: A solution using Bash (cygwin) would also work for me since i just need to do this once.

+1  A: 

No idea how to do this in a batch file, but A bash solution is simply:

find . -name .svn -prune -o -print | egrep "/~.*|/[^/].*\.~.*$|/Thumbs.db" | xargs rm -f

Although I recommend redirecting to a file first and then eyeballing the files.

The first command finds everything not in a .svn subdir. The second command selects those things you want to delete, and the third deletes them.

Dean Povey
Thank you! However, the xargs rm -f is not working, it is not deleting the files
jzuniga
If you remove the xargs do you get a list of files? xargs just takes the standard input and creates arguments for the program passed to it. It is possible that the regular expression is above is not correct, you may have to tweak it a bit.
Dean Povey
+2  A: 
del ~*.*
del *.~*
del Thumbs.db
for /d %%a in (*) do (
    if not "%%a" == ".svn" (
      cd %%a
      del /s ~*.*
      del /s *.~*
      del /s Thumbs.db
      cd ..
    )
)
Dim_K
Excellent ! Thank you!
jzuniga