0

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"
jburto121
  • 21
  • 5
  • Your question is currently off-topic; posting something which doesn't attempt to address the issue, and asking for it to address the issue is lazy and rude as it shows no effort whatsoever. Please attempt to solve your own issue before expecting us to assist you. – Compo Apr 11 '18 at 14:03
  • Apologies, I have attempted, but without success. It keeps removing the 'production' folder recursively. I cannot figure out how to exclude. – jburto121 Apr 11 '18 at 14:59
  • jburto121, your question must include the code you have run which attempts to meet the intended goal, _not what you've currently included_. Where that fails to work, you also include with it a full explanation of what happens when you invoked it, showing any errors and the before and after results. We can then help you with the specific issue(s) relevant to that information. – Compo Apr 11 '18 at 15:21

0 Answers0