DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
// DOS loop to delete files by mask, including subdirs. // In this example, all .BAK files in drive C: will be deleted. // Note1: If you plan to run it directly in the DOS prompt, use just %G in place of %%G // Note2: naturally, you can run any other command than DEL"
FOR /F "tokens=*" %%G IN ('dir C:\*.bak /b /s') DO DEL "%%G"