Exclude a folder inside temp when executing a del batch file

前端 未结 1 851
日久生厌
日久生厌 2021-01-20 04:24

What do I add to my DEL batch file if I want to exclude a folder inside a folder I want to delete?

I have this code to delete my all the contents of the temp folder<

1条回答
  •  北海茫月
    2021-01-20 04:57

    Here's some batch script code that'll do what you're asking.

    for /d %%I in (c:\temp\*) do (
        if /i not "%%~nxI" equ "imptfolder" rmdir /q /s "%%~I"
    )
    del /q c:\temp\*
    

    If you're just entering these commands from the console, use single percents rather than double.

    cd /d c:\temp
    for /d %I in (*) do @(if /i not "%~I" equ "imptfolder" rmdir /q /s "%~I")
    del /q *
    

    0 讨论(0)
提交回复
热议问题