Batch command to delete all subfolders with a specific name

前端 未结 3 1226
一个人的身影
一个人的身影 2021-01-30 09:00

I have a directory as such:

D:\\Movies
D:\\Movies\\MovieTitle1\\backdrops\\
D:\\Movies\\MovieTitle2\\backdrops\\
D:\\Movies\\MovieTitle3\\backdrops\\
D:\\Movies\         


        
3条回答
  •  余生分开走
    2021-01-30 09:34

    Short answer:

    FOR /d /r . %%d IN (backdrops) DO @IF EXIST "%%d" rd /s /q "%%d"
    

    I got my answer from one of the countless answers to the same question on Stack Overflow:

    Command line tool to delete folder with a specified name recursively in Windows?

    This command is not tested, but I do trust this site enough to post this answer.

    As suggested by Alex in a comment, this batch script should be foolproof:

    D:
    FOR /d /r . %%d IN (backdrops) DO @IF EXIST "%%d" rd /s /q "%%d"
    

提交回复
热议问题