删除目录
    /P 表示目录
    /S 表示递归向下查询子目录
    /D 表示date -460 意思是460天以前 或者 -2018/11/9 表示这个日期以前的
    /C 开始执行命令 内部还有一个cmd
    @ISDIR==TRUE 表示判断是不是目录
    RD 表示删除目录(文件夹)/s 表示可以删除非空的文件夹 /q 安静模式,不需要停下来回应是否因该删除
    示例:
    E:\data\bpt\log\ABC>FORFILES /P E:\data\bpt\log /S /D -460 /C “cmd /c if @ISDIR
    ==TRUE RD /s /q @PATH” >>E:\data\bpt\log\del.log

    1. rem @echo off
    2. rem logpath
    3. set LogPath="C:\OMD_Feeder_Client\OMD_Feeder_Client_v1.9.4\log"
    4. rem record del_log process
    5. set DelLog="C:\OMD_Feeder_Client\OMD_Feeder_Client_v1.9.4\del_old.log"
    6. echo ----------------------------------------------- >>%DelLog%
    7. rem days
    8. set DaysAgo=7
    9. echo delete the old files start at %Date% - %time% >>%DelLog%
    10. rem del cmd
    11. rem FORFILES /P C:\OMD_Feeder_Client\OMD_Feeder_Client_v1.9.4 /S /D -460 /C "cmd /c if @ISDIR==TRUE echo @PATH" >>%DelLog%
    12. FORFILES /p %LogPath% /s /m *.* /d -%DaysAgo% /C "cmd /c del @path" >>%DelLog%
    13. echo delete the old files end of %Date% - %time% >>%DelLog%
    14. echo ----------------------------------------------- >>%DelLog%
    1. rem @echo off
    2. rem logpath
    3. set LogPath="E:\data(1)\data\bpt\log"
    4. rem record del_log process
    5. set DelLog="%LogPath%\del_old.log"
    6. echo ----------------------------------------------- >>%DelLog%
    7. rem days
    8. set DaysAgo=30
    9. echo delete the old files start at %Date% - %time% >>%DelLog%
    10. rem del cmd
    11. rem FORFILES /P E:\data\bpt\log /S /D -460 /C "cmd /c if @ISDIR==TRUE echo @PATH" >>%DelLog%
    12. FORFILES /P %LogPath% /S /D -%DaysAgo% /C "cmd /c if @ISDIR==TRUE echo @PATH && RD /s /q @PATH" >>%DelLog%
    13. echo delete the old files end of %Date% - %time% >>%DelLog%
    14. echo ----------------------------------------------- >>%DelLog%

    image.png
    win7下创建定时任务
    image.png
    image.png