@setlocal enableextensions enabledelayedexpansion
@echo off
color a

set "SOURCE_DIR=C:\DevConsole"
set "ROOT_GAME_DIR=%~dp0"
for /d %%d in (*.*) do ( echo.%%d | findstr /C:"_Data">nul && (set "DATA_DIR=%ROOT_GAME_DIR%%%d") )
set "MANAGED_DIR=%DATA_DIR%\Managed"

REM Make Backups
mkdir Backups
xcopy "%MANAGED_DIR%\Assembly-CSharp.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%MANAGED_DIR%\Assembly-CSharp-firstpass.dll" "%ROOT_GAME_DIR%Backups\" /Y
REM Try to backup Mono DLL
xcopy "%DATA_DIR%\Mono\mono.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%DATA_DIR%\Mono\mono-2.0-bdwgc.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%DATA_DIR%\Mono\EmbedRuntime\mono.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%DATA_DIR%\Mono\EmbedRuntime\mono-2.0-bdwgc.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%ROOT_GAME_DIR%Mono\mono.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%ROOT_GAME_DIR%Mono\mono-2.0-bdwgc.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%ROOT_GAME_DIR%Mono\EmbedRuntime\mono.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%ROOT_GAME_DIR%Mono\EmbedRuntime\mono-2.0-bdwgc.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%ROOT_GAME_DIR%MonoBleedingEdge\EmbedRuntime\mono.dll" "%ROOT_GAME_DIR%Backups\" /Y
xcopy "%ROOT_GAME_DIR%MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll" "%ROOT_GAME_DIR%Backups\" /Y

REM Put DevConsole in Place
xcopy "%SOURCE_DIR%\DevConsoleLoader.dll" "%ROOT_GAME_DIR%" /Y
xcopy "%SOURCE_DIR%\DevConsole.dll" "%MANAGED_DIR%\" /Y
xcopy "%SOURCE_DIR%\Mono.CSharp.dll" "%MANAGED_DIR%\" /Y
xcopy "%SOURCE_DIR%\DevConsoleMod" "%DATA_DIR%\DevConsoleMod\" /Y /S /E

PAUSE