views:

46

answers:

3
+1  Q: 

cleanup batch file

I'm writing a batch file to cleanup my source folders. I want to delete all wincvs generated files with a prefix of .#

FOR /F "tokens=*" %%G IN ('DIR /B .#*.*') DO DEL "%%G"

the problem I'm having is that it's not deleting my files within subdirectories.

+2  A: 

I think you need DEL /S

Ariel
+1, easier than mine =)
Rubens Farias
I don't think kevin is looking to delete directories recursively, but rather find the files within directories, and then delete them.
mlathe
yup missing the /S in the DIR
Kevin
he probably meant `DEL /S .#*.*`
Rubens Farias
A: 

What about this:

FOR /R C:\FOLDER\SUBFOLDER %%G IN (.#*.*) DO DEL %%G
Rubens Farias
I didn't get your solution to work, but I just noticed it's missing a leading period in .#*.*
Kevin
sorry kevin, I didn't tested it before, but now it works; do you want to give a try?
Rubens Farias
yeah still no luck. not sure what the issue is
Kevin
well, that meant to run inside a batch file; if you try to run directly at command prompt, you should to remove a %;
Rubens Farias
+1  A: 

you probably want to do

DIR /S /B .#*.*

to list out the directories recursively

mlathe