python版本为:2.7 import os import sys import time # Sets how many days old files are deleted DAYS_N = 7 # To delete the path and the following subfiles PATH = r'C:\inetpub\logs\LogFiles' def deletefile(PATH): for eachfile in os.listdir(PATH): filename =
原文:用批处理文件自动备份文件及文件夹,并自动删除n天前的文件 ---恢复内容开始--- 下是备份的批处理,添加到"计划任务"中,设定时间自动运行 复制代码 代码如下:@echo off rem 格式化日期 rem date出来的日期是"2006-02-22 星期三",不能直接拿来使用,所以应该先格式化一下 rem 变成我们想要的.date:~0,4的意思是从0开始截取4个字符 set d=%date:~0,4%%date:~5,2%%date:~8,2% rem