How to delete *.* excluding some extensions?

前端 未结 6 2147
夕颜
夕颜 2020-12-10 05:46

I\'m trying to make a batch file on Windows for deleting all the files in the current directory but excluding 4 file extensions (log, sdb, SDK, bat).

I have tried th

6条回答
  •  执笔经年
    2020-12-10 06:30

    forfiles /s /c "cmd /c (if NOT @ext==\"dqy\" del /s /q @path)" /D -14
    

    This is about as simple as I could get this script. They wanted to keep the macro files (.dqy) but recursively delete everything else older than 14 days.

    Runs in the current directory (be careful when testing).

提交回复
热议问题