7 zip 建立自動釋放程式怎麼刪除原始檔
- 2021-11-21
嗯……
借用powershell可以輕鬆實現,批處理做起來有點麻煩。但既然要求用批處理,只有將powershell化為bat了。
新建文件,儲存下面程式碼,另存為bat格式時用ansi編碼,否則螢幕提示的漢字可能會亂碼。
其實,看起來亂,下面的程式碼只有兩行。
要改的地方只有$sdir=‘d:\data’,將單引號中的內容改為要監控的路徑
@echo off
powershell -c “$sdir=‘d:\data’;cd $sdir;while (1) {$fso=(ls *。* -recurse -force |sort-object creationtime -descending);foreach($file in $fso){ if ($file。creationtime。month -lt 10) {$month=-join(‘0’,$file。creationtime。month)} else {$month=$file。creationtime。month};if ($file。creationtime。day -lt 10) {$day=-join(‘0’,$file。creationtime。day)} else {$day=$file。creationtime。day};if ($file。creationtime。hour -lt 10) {$hour=-join(‘0’,$file。creationtime。hour)} else {$hour=$file。creationtime。hour}; if ($file。creationtime。minute -lt 10) {$minute=-join(‘0’,$file。creationtime。minute)} else {$minute=$file。creationtime。minute};$fdate=-join(‘[’,$file。creationtime。year,$month,$day, $hour, $minute,‘]’);$fname=-join($fdate,$file。name);if (!($file。name)。contains($fdate)){ echo 發現新檔案:$file;rename-item -path $file。fullname -newname $fname } }}”
上一篇:中國文學代表作是什麼
下一篇:電視機機頂盒遙控器怎麼設定