使用forfiles 刪除幾天前的數(shù)據(jù)
rem 刪除前一天的歷史數(shù)據(jù)
forfiles /m *.fc /s /D -1 /c "cmd /c del @file" rem 刪除當(dāng)前目錄下及其子目錄中的空文件夾 在批處理中把%改成%% Forfiles windows server 2003內(nèi)置命令 開關(guān)很少,p路徑,m 方式,s包含子目錄,c執(zhí)行命令,d日期 普通使用可能比不上for,dir等, 但是c這個(gè)開關(guān)很強(qiáng)大的 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天內(nèi)修 改過的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 列出一天前到現(xiàn)在修改過的exe文件 列出doc文件,并打印出文件大小 FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file" 列出txt文件, 如果不是文件夾,那么就依次用notepad打開該文件,關(guān)閉后開啟下一個(gè)文件。 |
|