简体   繁体   English

命令删除Windows 7中超过10天的文件夹,例外

[英]command to delete folders older than 10 days in Windows 7 with exceptions

I need to delete folders in a specific directory which weren't modified for more than 30 days. 我需要删除特定目录中超过30天未修改的文件夹。 So I have this below command which works perfectly: 所以我有下面的命令,它可以很好地工作:

FORFILES /S /D -30 /C "cmd /c IF @isdir == TRUE rd /S /Q @path"

My question is how do I exclude a specific folder called "DoNotDelete" when running this command? 我的问题是在运行此命令时如何排除名为“ DoNotDelete”的特定文件夹?

Check for the name of the directory to be omitted. 检查要省略的目录名称。 When you are confident that only the correct directories will be removed, delete the echo from the rd command. 当您确定仅会删除正确的目录时,请从rd命令删除echo

FORFILES /S /D -30 /C ^
    "cmd /c IF @isdir == TRUE (IF /I @file NEQ DoNotDelete (echo rd /S /Q @path))"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM