LoginSignup
0
1

More than 3 years have passed since last update.

【bat】7日より前のバックアップフォルダを削除する

Posted at

やりたいこと

C:\tmp下にバックアップ用のログが格納されていくので、
7日より前のフォルダをタスクスケジューラを使って自動で削除したい。

log_del.bat
 forfiles /P C:\tmp /D -8 /C "cmd /c if @isdir==TRUE rmdir /S /Q @path"
 pushd C:\tmp 
 for /f %%A in ('dir /ad /b') do rd %%A

コード内容

1行目のforfilesコマンドで対象ディレクトリの下を削除する
2・3行目で空のディレクトリを削除する

0
1
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
0
1