Prevent command "del /s" from entering a folder
I need to recursively remove unnecessary fil开发者_StackOverflow社区es 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.
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 ..
)
)
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.
精彩评论