LoginSignup
1
3

More than 5 years have passed since last update.

ファイルを自動でバックアップする(Windows)

Posted at

概要

Windowsバッチを作成して、スタートアップにセットしておけばWindows起動の度に自動で特定のファイルをバックアップしてくれるバッチ。ファイル名にバックアップした日時を付けて保存する。
意外と使うので備忘録。

環境

  • Windows

方法

1.下記バッチを作成する。

filebackup.bat
@echo off
REM ファイルバックアップバッチ
set dt=%date:~0,4%%date:~5,2%%date:~8,2%
set tm=%time: =0%
set tm=%tm:~0,2%%tm:~3,2%%tm:~6,2%%tm:~9,2%
REM ★任意のファイル名
set fn=ほげほげファイル-%dt%_%tm%.txt
echo %fn%
REM ★任意のコピー元ファイルパス
set pathfrom="\\192.168.xxx.xxx\xxxx\xxxx.txt"
REM ★任意の¥コピー先ファイルパス
set pathto="C:\xxxx\"%fn%
copy /B /Y /Z %pathfrom% %pathto%
exit /b 0

2.作成したバッチをスタートアップまたは、タイマー起動などで定期的に実行させる。

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