Last active
December 31, 2017 00:23
-
-
Save gologius/74ae221b6d09be98261db57a169b4492 to your computer and use it in GitHub Desktop.
バックアップと、バックアップ先のファイルを一定期間後に削除するバッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem 【コピー元のフォルダの新規ファイルをコピーする。】 | |
rem /S サブディレクトリをコピーします。 このオプションでは、空のディレクトリをコピーしないことに注意してください。 | |
rem /R:n 失敗したコピーに対する再試行数: 既定値は 1,000,000。 | |
rem /W:n 再試行と再試行の間の待機時間: 既定値は、30 秒です。 | |
rem /XJD フォルダの接合ポイントを除外します。 ジャンクションという特殊ファイルをコピー対象から外します。 | |
rem /XJF ファイルの接合ポイントを除外します。ジャンクションという特殊ファイルをコピー対象から外します。 | |
@echo on | |
robocopy C:XXXXXX\XXXXX C:\yyyy\yyyyy /S /W:5 /XJF /XJD | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem 【指定日以前(以降)のファイルを削除】 | |
rem 【ログファイルも出力される】 | |
rem /P パス名指定 | |
rem /S サブディレクトリに対しても処理を行う | |
rem /D 日付指定(-1 や +2011/11/11) | |
rem /C コマンド実行 | |
rem @path forfilesで取得したファイル名(絶対パス) | |
rem del /Q 削除時に確認しない | |
@echo on | |
set targetPath=C:\XXXXXX | |
set nowTime=%DATE:~-10,4%%DATE:~-5,2%%DATE:~-2%_%TIME:~0,2%%TIME:~3,2% | |
forfiles /P %targetPath% /S /D -1 /C "cmd /c echo @path >> %targetPath%\%nowTime%.log" | |
forfiles /P %targetPath% /S /D -1 /C "cmd /c del /Q @path" | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment