刪除 n天前檔案的方法:Belvedere、Xdel與DelAge32
同事提出了一個需求:每天定期刪除10天前檔案的方法。我第一個想到的是以前介紹過的這個Belvedere: 檔案管理自動化工具,但另一個同事提出了更好的工具:xdel。
xdel.exe是一個13KB的執行檔,由命令行執行,可以做一個批次檔再放到啟動資料夾裡每天定時執行。
xdel [-listonly] [-dirsonly|-filesonly] [-recurse] [-dolog] [-ctime TIME|-mtime TIME] [-debug] dir[pattern]
XDEL範例
刪除建檔日期5天前的c:\temp資料夾裡的*.log:
xdel -ctime Now-5d "c:\temp\*"
星號就是pattern,可惜我在Windows 7裡使用*.log時程式會當掉,用「*」,「任何字串*」則可將正常執行。
刪除異動日期10天前的檔案:
xdel -mtime Now-10d "c:\temp\*"
- 加了-recurse則其下子目錄裡符合日期的檔案會一併刪除
- -listonly:只顯示符合條件的檔案或資料夾,不會實際執行刪除的動作
- -dirsonly:只刪除符合條件的資料夾
- -filesonly:只刪除符合條件的檔案(預設選項)
完整說明看readme.txt就可以了。
XDEL資訊
- 官網:http://sourceforge.net/projects/xdel/
- 直接下載:http://sourceforge.net/projects/xdel/files/latest/download
DELAGE32
delage32.exe是另一個相同功能的程式,提供的選項更多,且可指定*.log這樣的參數。
- 下載:http://www.horstmuc.de/wbat32.htm 右上角有Download
- 說明網頁:http://www.horstmuc.de/win/delage.htm
- 指令不輸入選項時顯示出來的說明:
DelAge32 - ver. 2.3 (c) 2003-2008, Horst Schaeffer Deletes or moves files (path with file pattern) by age (number of days) Syntax: DelAge32 filespec age [options] Options: /created /accessed /modified (default) - file stamp used to evaluate age /includeRO - include read-only files /includeH - include hidden files /includeS - include system files /includeRHS -include read-only, hidden and system files /recurse - include subdirectories /subonly - /recurse excluding initial directory /rd - remove empty subdirectories /move path - move files to specified path /preview - list, but no action /quiet - no output
- 範例:刪20天前的*.log,且移除空的資料夾
delage32 e:\*.log 20 /rd
##
您可能也會有興趣的類似文章
- 刪除n天前的檔案工具 DelAge32.exe已能處理Unicode檔名 (0則留言, 2015/04/14)
- Belvedere: 檔案管理自動化工具 (0則留言, 2008/02/01)
- 快速下載卡提諾/伊莉論壇小說的方法:使用JNovelDownloader (0則留言, 2019/04/14)
- Ubuntu與Windows皆能使用的剪貼簿工具:CopyQ (2則留言, 2013/12/28)
- HDDB:快速搜尋檔名的類Everything工具 (0則留言, 2014/08/20)
- Dropbox服務四之二:快速複製檔案到Dropbox的小工具DropBoxCopy (0則留言, 2012/04/28)
- HFS(HTTP File Server)讓您瞬間速架私人FTP (6則留言, 2008/02/05)
- 用cPanel Proxy穿透防火牆以操作網站cPanel後台 (0則留言, 2010/06/21)
- [Obs#65] Obsidian exporter:將儲存庫匯出成標準Markdown格式 (0則留言, 2022/01/09)
- jQuery神奇的選擇器(Selector) (3則留言, 2007/09/28)
- WinMerge檔案濾鏡的使用方法 (0則留言, 2006/09/10)
- [Windows] 用Gitea架設自用的Git Server (2則留言, 2017/07/21)
- Windows執行檔的各種啟動方法(初學者的命令行 #2 ) (0則留言, 2019/03/31)
- [Database] Aqua Data Studio 4.0.2推出 (0則留言, 2005/02/23)
- ConEmu的常用設定與基本操作(初學者的命令行 #1) (0則留言, 2019/03/31)
不錯的工具軟體,看能否再增加參數,不刪除子資料夾底下檔案。
我後來都是用delage64, 預設不處理子目錄,加了 -recurse才會處理子目錄。
http://www.horstmuc.de/win/delage-de.htm
我是用DelAge32, Version 2.3 這套也不錯喔
感謝分享,DelAge32也很棒,已經加入其說明了。