Monday, November 15, 2004

Remove Hidden Folders Recursively in Windows

In a Windows XP machine there's a folder copied from a Unix machine which contains many useless and hidden .cache folders. Following script can delete all these hidden folders recursively in DOS command line:

C:\temp>for /f "tokens=* delims=" %x in ('dir /s /b /a:d *cache') do rd /s /q "%x"

Alternatively we can create .bat batch file so we can just click it to run the script, but the token needs to be changed from %x to %%x:

for /f "tokens=* delims=" %%x in ('dir /s /b /a:d *cache') do rd /s /q "%%x"