mpir/build.vc/out_copy_rename.bat

37 lines
716 B
Batchfile
Raw Normal View History

2015-06-06 05:12:40 -04:00
@echo off
rem %1 = source file path
rem %2 = destination directory
rem %3 = destination file name
2015-06-06 05:12:40 -04:00
if not exist %1 goto nofile
if exist %2 goto next
2015-11-17 07:16:34 -05:00
echo creating directory %2
2015-06-06 05:12:40 -04:00
md %2 > nul
:next
rem strip quotes if present
set str=%2
for /f "useback tokens=*" %%a in ('%str%') do set str=%%~a
rem add a backslash if the output directory lacks one
set str=%str:~-1%
if "%str%" == "\" (set outf=%2%3) else (set outf=%2\%3)
2015-07-22 17:39:24 -04:00
set op=copying
2015-06-06 05:12:40 -04:00
if not exist "%outf%" goto copy
rem don't overwrite if output exists and is not changed
fc %1 %outf% > nul && if not %errorlevel 1 goto exit
2015-07-22 17:39:24 -04:00
set op=overwriting
2015-06-06 05:12:40 -04:00
:copy
2015-11-19 11:30:52 -05:00
if "%4" NEQ "" (echo %op% %outf% from %1)
2015-06-06 05:12:40 -04:00
copy %1 %outf% > nul
goto exit
:nofile
echo %1 not found
:exit