使用forfiles 删除几天前的数据
rem 删除前一天的历史数据
forfiles /m *.fc /s /D -1 /c "cmd /c del @file" rem 删除当前目录下及其子目录中的空文件夹 在批处理中把%改成%% Forfiles windows server 2003内置命令 开关很少,p路径,m 方式,s包含子目录,c执行命令,d日期 普通使用可能比不上for,dir等, 但是c这个开关很强大的 command string:
FORFILES /S /M *.txt /C "cmd /c type @file | more" FORFILES /P C:\ /S /M *.bat FORFILES /D -30 /M *.exe /C "cmd /c echo @path 0x09 was changed 30 days ago" 列出30天内修 改过的exe文件,列出路径+自定义文字0x09(tab) was changed 30 days ago FORFILES /D 2001/01/01 /C "cmd /c echo @fname is new since Jan 1st 2001" 列出 2001、0101后的文件并打印文档名字+is new since Jan 1st 2001 FORFILES /D +2009/4/10 /C "cmd /c echo @fname is new today" 列出20090410后修改过的文 件,并打印 FORFILES /M *.exe /D -1 列出一天前到现在修改过的exe文件 列出doc文件,并打印出文件大小 FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file" 列出txt文件, 如果不是文件夹,那么就依次用notepad打开该文件,关闭后开启下一个文件。 |
|