2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windowsのbatファイルで古いファイルを削除するメモ

Posted at

よく忘れるのでメモ。

del.bat
rem c:\log\~.log に削除処理結果を残す
set fname=c:\log\%date:~-10,4date:~-5,2date:~-2,2%.log

rem 50日経ったc:\backup\~.bakファイルを削除
forfiles /P c:\backup\~.bak /S /M *.log /C "cmd /c if @isdir==FALSE del /s @path" /D -50 1>> %fname%

Windowsのforfilesコマンドで条件に合うファイルを取り出して処理する
http://www.atmarkit.co.jp/ait/articles/0902/27/news132.html

バッチ・ファイル中で日付をファイル名に使用する
http://www.atmarkit.co.jp/ait/articles/0405/01/news002.html

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?