I noticed the post regarding
Command line tool to delete folder with a specified name recursively in Windows?
However, I want to include a folder with the same name as an exclusion for a sub folder. eg. Using- 'Production'; and wish to exclude a folder /Views/Production and I tried using If not exist 'Views\Production' without success.
So I should see:
-- Before delete
Root
\Production
\Views
\Production
-- After delete
Root
\Views
\Production
My script:
ECHO Removing all folder instances of 'Production' (Warning: Avoid Views\Production)
for /d /r . %d in (Production) do @if exist "%d" rd /s/q "%d"