iT邦幫忙

0

請問指定時間刪除檔案的軟體嗎?

v60i 2013-06-07 15:59:219141 瀏覽
  • 分享至 

  • xImage

我的 PC 軟體中會一直產生LOG檔
目前都是用手動刪除
請問有可以設定刪除N天前的軟體嗎?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
12
vino1
iT邦大師 1 級 ‧ 2013-06-07 16:31:12
最佳解答

這套免費軟體 waRmZip ... 您可以參考看看

批次檔範例如下

rem 壓縮昨天的 log
waRmZip.wsf /r /q /f:.log "C:\WINDOWS\system32\Logfiles" /ca:1 /cp:"c:\Scripts\7za.exe" /cpp:"a -tzip $out $in"

rem 刪除30天前的 log 檔
waRmZip.wsf /r "C:\WINDOWS\system32\Logfiles" /da:30 /df /q

rem 搬移30天前的 log 檔到指定資料夾 (D:\LogFiles)
waRmZip.wsf /r /q "c:\WINDOWS\system32\LogFiles" /ma:30 /md:D:\LogFiles

waRmZip 官方下載
http://winadmin.forret.com/

12
hon2006
iT邦大師 1 級 ‧ 2013-06-07 17:38:44

可以用 forfiles 指令,windows 7 有內建,xp 要另外下載.
範例(刪除7天前的檔案)
forfiles /p "D:\*.log" /s /d -7 /c "cmd /c del @FILE"
(把他存成 x.bat 排程執行)
下載
http://windowallos.com/bbs/board.php?bo_table=winxp_eng_x64&wr_id=685
教學
http://windowsitpro.com/systems-management/forfiles-processes-scripts-without-scripts

建議自己寫...好玩XD
我是用VBS寫的
還可以備份
http://jufmore.blogspot.tw/2012/09/vbs.html
附送懶人包
不過可以自己寫比較好玩XD..

4
funforever
iT邦新手 4 級 ‧ 2013-06-07 18:11:12

另外PC清LOG或TEMP檔,推薦Ccleaner
請愛用正版臉紅

看更多先前的回應...收起先前的回應...
蟹老闆 iT邦大師 1 級 ‧ 2013-06-09 01:13:52 檢舉

funforever提到:
另外PC清LOG或TEMP檔,推薦Ccleaner

Orz

v60i iT邦新手 4 級 ‧ 2013-06-10 00:27:47 檢舉

大哥...別鬧了

ㄜ~怎麼了~~小弟不解暈
是我太笨了嗎毆飛

Ccleaner可以清軌跡(軟體生成的log&temp)阿~你是說workstaion(個人PC),而不是server吧
server我就不敢用了~怕有vulnerablity的問題~

v60i iT邦新手 4 級 ‧ 2013-06-10 23:35:43 檢舉

沒有阿,您回答得也很棒
只不過不是我要的
我要的是從今天起往前保留N天
其餘刪除
不是全刪

寫程式指定資料夾~

<pre class="c" name="code">Dim objFSO, objFolder ,backuplog 
dim filesys, filetxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8 
'=============================================================================
'定義變數區塊

'目的資料夾(刪除過期資料夾用)
strPath = "C:\backup\"
'紀錄檔位置
backuplog = ".\backup_log.txt"
'設定要留下多少天之前的資料
Const intDaysOld = 30
'=============================================================================
Dim objFSOS : Set objFSOS = CreateObject("Scripting.FileSystemObject")
Dim objFolderS : Set objFolderS = objFSOS.GetFolder(strPath)
Dim objSubFolder
For Each objSubFolder In objFolderS.SubFolders
If objSubFolder.DateLastModified < DateValue(Now() - intDaysOld) Then
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile(backuplog, ForAppending, True) 
filetxt.WriteLine(  now() & "已刪除-->" & objSubFolder)
filetxt.Close
         objSubFolder.Delete True
    End If
Next
wscript.quit

試試看~我還沒除錯~用文字檔存*.VBS

我要發表回答

立即登入回答