@echo off 
@title RothenburgAR Deploy

rem DO NOT FORGET TO MODIFY THIS VARIABLES
SET adbPath=C:\Program Files\Unity\Editor\Android\platform-tools\adb.exe
SET ApkPath=..\Output\rc3.apk

SET DataSourcePath=%appdata%\..\LocalLow\FHWS\RothenburgAR\data\
SET DataTargetPath=/storage/emulated/0/Android/data/de.fhws.rothenburgar/files/data/

SET ClearBeforeCopy=1

rem Scipt start
FOR /F "tokens=1,2 skip=1" %%R IN ('"%adbPath%" devices') DO (
    echo ### DEVICE %%R START
    CALL :HandleDevice %%R
    echo ### DEVICE %%R DONE
)

EXIT /B %ERRORLEVEL%

rem #################################
rem Here I declare some Methods

rem Copies data/%2 to device %1
:CopyData
echo Copying data/%2 to device %1
"%adbPath%" -s %1 push %DataSourcePath%\%2 %DataTargetPath%/%2
EXIT /B 0


rem Handles a device
rem requires %1 to be the id of the device
:HandleDevice
echo Installing "%ApkPath%" to device %1.
"%adbPath%" -s %1 install -r "%ApkPath%"

if "%ClearBeforeCopy%"=="1" (
    echo Clearing data on device %1.
    "%adbPath%" -s %1 shell rm -r %DataTargetPath%
)

CALL :CopyData %1 colors.xml
CALL :CopyData %1 localization.xml
CALL :CopyData %1 localization
CALL :CopyData %1 exhibition
CALL :CopyData %1 poi
EXIT /B 0