@echo off
@rem 第1引数で指定したファイルを、第2引数で指定したフォルダに移す
if (%2)==() goto error
if exist %1 goto del_old
echo "ERROR: not found %1"
goto exit
:del_old
@rem 移動先に同名のファイルがあったら消す
if exist %2\%1 del %2\%1
@rem 移動先に同名のファイルが無ければ移動処理(move_to)へ進む
if not exist %2\%1 goto move_to
@echo "ERROR: could not delete old file"
goto exit
:move_to
@copy %1 %2\%1
if exist %2\%1 goto del_src
@echo "ERROR: could not copy"
goto exit
:del_src
del %1
if not exist %1 goto finish
@echo "ERROR: could not delete original file"
goto exit
:finish
@echo "%0 is finished."
goto exit
:error
@echo "Usage: %0 source dest"
:exit