

@echo off

rem
rem 1  absolute source directory
rem 2  file name
rem 3  absolute installation directory
rem

set source_dir=%1%
set file_name=%2%
set install_dir=%3%

if "%source_dir%"=="" exit /B 0
if "%file_name%"=="" exit /B 0
if "%install_dir%"=="" exit /B 0

set dest_file_path=%install_dir%\%file_name%
set ref_file=%dest_file_path%.cmtref
set full_source_name=%source_dir%\%file_name%

if %install_dir%=="" exit /B 0

if NOT exist %install_dir% mkdir %install_dir%

if NOT exist %install_dir% echo "Cannot install file %file_name%, no installation directory specified" & exit /B 0

echo Installing file %file_name% into %install_dir%

if exist %dest_file_path% del %dest_file_path%

if exist %ref_file% del %ref_file%

copy /Y %full_source_name% %dest_file_path%
echo %full_source_name% >%ref_file%
