Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a batch file to delete files with wildcards

I have multiple websites set up in the same folder, and I want to create a batch file that will delete the cache in each of them without having to add a new line for each site. For example I am using this:

del /S /Q D:\www\site-name\cache\*

Which works, but I have to add a new line for every site in D:\www. The del command doesn't support:

del /S /Q D:\www\*\cache\*

So what is a better way to do this?

like image 304
jeff1234567890 Avatar asked Mar 31 '10 22:03

jeff1234567890


1 Answers

I think this should work:

for /D %%f in ("D:\www\*") do @(
del /S /Q "%%f\cache\*"
)
like image 113
Adisak Avatar answered Oct 04 '22 01:10

Adisak