The MOVE command moves one or more files from one directory to the target directory. The syntax is:

move <source> <target>


<source> specifies the path and name of the file(s) to move.

<target> specifies the path and name to move file(s) to.

After a MOVE statement, the <source> file(s) no longer exists and the <target> file(s) have the same permissions (ACL) as they did in the <source> folder.

When using the MOVE command, you will receive

Cannot create a file when that file already exists.

if any <target> file already exists.

I have scripted MV.BAT to circumvent this problem. The syntax is:

mv <source> <target>

Wildcards (*) are supported. Examples:

mv <Drive:>\SourceFolder\*.log <Drive:>\TargetFolder\*.log
mv <Drive:>\SourceFolder\*.log <Drive:>\TargetFolder\*.txt
mv <Drive:>\SourceFolder\*.log <Drive:>\TargetFolder\*.*
mv <Drive:>\SourceFolder\file*.log <Drive:>\TargetFolder\*.log

MV.bat contains:

@echo off
if %2<h1><a name="_goto_syntax_set_p1_1_set_p2_2_set_p2_p2_set_p2_p2_set_fp1_DP1_set_fp2_DP2_set_f2_N2_set_x2_X2_if_f2_">"" goto syntax
set p1=%1
set p2=%2
set p2=%p2:"=%
set p2="%p2%"
set fp1=%~DP1
set fp2=%~DP2
set f2=%~N2
set x2=%~X2
if "%f2%"</a></h1>"" set f2=*
if "%x2%"<h1><a name="_set_x2_set_px_fp2_f2_x2_if_i_p2_">"." set x2=.*
set px="%fp2%%f2%%x2%"
if /i %p2%</a></h1>%px% goto same
set px="%fp2%%f2%.*"
if /i %p2%<h1><a name="_px_set_x2_amp_goto_same_set_f2_same_pushd_fp1_for_f_Tokens_i_in_dir_b_p1_do_call_movit_i_popd_endlocal_goto_end_syntax_echo_Syntax_MV_lt_source_gt_lt_target_gt_endlocal_goto_end_movit_set_p2_fp2_f2_x2_if_f2_">%px% set x2=.*&goto same
set f2=*
pushd %fp1%
for /f "Tokens=*" %%i in ('dir /b %p1%') do call :movit "%%i"
goto end
@echo Syntax - MV <source> <target>
goto end
set p2=%fp2%%f2%%x2%
if "%f2%"</a></h1>"*" goto move2
if "%x2%"<h1><a name="_set_p2_fp2_f2_X1_move1_if_exist_p2_del_q_f_p2_move_1_p2_goto_end_move2_set_p2_fp2_N1_x2_if_x2_">".*" set p2=%fp2%%f2%%~X1
if exist "%p2%" del /q /f "%p2%"
move %1 "%p2%"
goto end
set p2=%fp2%%~N1%x2%
if "%x2%"</a></h1>".*" set p2=%fp2%%~N1%~X1
goto move1