Friday, May 17, 2013

Wildcard Removal of Folder

An old classic trick for removal of folders in DOS using a wildcard. Remember this should be deprecated in deference to PowerShell but I thought I'd get it on here anyway.

For this example we want to delete any folder ending in '_old' e.g. 'MicksFolder_old'


for /d %a in (*_old) do rd /s /q "%a"

Remember, this is correct on the CMD line but if you place it in a script you will have to double the % symbols i.e.

for /d %%a in (*_old) do rd /s /q "%%a"

Cheers

No comments:

Post a Comment