zoukankan      html  css  js  c++  java
  • Windows ForFiles 删除 过期 文件

    @echo off
    
    set logFile=DELETE_DOS.log
    set weekName=WEEK
    set dayName=DAY
    
    echo --------- Delete Expired Files ------------ >> %logFile%
    
    echo Start (%date% %time%) >> %logFile%
    
    echo 删除文件夹 %weekName%  下过期 (30days) 的文件, Please wait... >> %logFile%
    forfiles /p "%weekName%" /m *.* /d -30 >> %logFile%
    forfiles /p "%weekName%" /m *.* /d -30 /c "cmd /c del @path" >> %logFile%
    
    echo 删除文件夹 %dayName% 下过期(7days)的文件, Please wait... >> %logFile%
    forfiles /p "%dayName%" /m *.* /d -7 >> %logFile%
    forfiles /p "%dayName%" /m *.* /d -7 /c "cmd /c del @path" >> %logFile%
    
    echo End (%date% %time%) >> %logFile%
    exit

    此DOS命令将删除WEEK(超过30天)和DAY(超过7天)文件夹下过期的文件,并将删除日志写入 DELETE_DOS.log

    另外,有关DOS中ECHO命令的用法,稍作整理:

    @ 关闭单行回显
    echo off   从下一行开始关闭回显
    @echo off  从本行开始关闭回显
    echo on   从下一行开始打开回显
    echo      显示当前是echo off/on状态
    echo.     输入回车换行,空白行,同(echo, echo; echo+ echo[ echo] echo/)

  • 相关阅读:
    AJAX跨域JS访问
    dd
    学习java,搭建一个英文名著轻松阅读网站
    超载问题求解!!!
    nginx + uwsgi 部署Django项目
    一种算法问题,求指点!
    js除法余数
    button捕捉回车键
    为SQL表添加全文索引范例
    .Net刷新页面的小结
  • 原文地址:https://www.cnblogs.com/icerainsoft/p/2772951.html
Copyright © 2011-2022 走看看