diff --git a/Unreal/SyncAvatarCore.bat b/Unreal/SyncAvatarCore.bat new file mode 100644 index 0000000..520e24b --- /dev/null +++ b/Unreal/SyncAvatarCore.bat @@ -0,0 +1,111 @@ +@echo off +setlocal EnableExtensions EnableDelayedExpansion + +rem ============================================================ +rem Mirror specific folders from A (AvatarBase) to B (this repo) +rem - Works relative to this .bat location +rem - Wipes extras in destination (/MIR) +rem - Logs removed extras (shown as *EXTRA File / *EXTRA Dir) +rem - Pauses before exit so console stays open +rem ============================================================ + +rem Destination root is the folder where this script lives +set "DST_ROOT=%~dp0" +if "%DST_ROOT:~-1%"=="\" set "DST_ROOT=%DST_ROOT:~0,-1%" + +rem Source root relative to this script +set "SRC_ROOT=%DST_ROOT%\..\..\AvatarBase\Unreal" + +rem Canonicalize paths +for %%I in ("%SRC_ROOT%") do set "SRC_ROOT=%%~fI" +for %%I in ("%DST_ROOT%") do set "DST_ROOT=%%~fI" + +echo ============================================================ +echo Robocopy Sync Script +echo ============================================================ +echo Source: %SRC_ROOT% +echo Destination: %DST_ROOT% +echo ============================================================ +echo. + +rem Guard: only intended for subprojects +if /I "%SRC_ROOT%"=="%DST_ROOT%" ( + echo ERROR: Source and destination are identical: + echo %SRC_ROOT% + echo This sync script is intended to be run from subprojects only. + echo. + pause + exit /b 1 +) + +if not exist "%SRC_ROOT%\" ( + echo ERROR: Source root does not exist: + echo %SRC_ROOT% + echo. + pause + exit /b 2 +) + +rem Timestamped log file +for /f %%I in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMdd_HHmmss"') do set "TS=%%I" +set "LOG_FILE=%DST_ROOT%\robocopy_sync_%TS%.log" + +rem List of folders to mirror +set "FOLDERS=Plugins\AvatarCore_AI Plugins\AvatarCore_Manager Plugins\AvatarCore_MetaHuman Plugins\AvatarCore_STT Plugins\AvatarCore_TTS Plugins\BLogger Plugins\BSettings Plugins\BTools Plugins\RuntimeMetaHumanLipSync_5.6 Content\Project" + +set "ANY_FAIL=0" + +for %%F in (%FOLDERS%) do ( + set "SRC=%SRC_ROOT%\%%F" + set "DST=%DST_ROOT%\%%F" + + echo ------------------------------------------------------------ + echo Mirroring: %%F + echo FROM: !SRC! + echo TO: !DST! + echo ------------------------------------------------------------ + + if not exist "!SRC!\" ( + echo WARNING: Source folder missing, skipping: !SRC! + echo WARNING: Source folder missing, skipping: !SRC!>>"%LOG_FILE%" + echo.>>"%LOG_FILE%" + pause + goto :continue + ) + + if not exist "!DST!\" ( + mkdir "!DST!" 2>nul + ) + + robocopy "!SRC!" "!DST!" /MIR /DCOPY:DAT /COPY:DAT /R:2 /W:1 /FFT /Z /NP /FP /TS /TEE /LOG+:"%LOG_FILE%" + set "RC=!ERRORLEVEL!" + + if !RC! GEQ 8 ( + echo ERROR: Robocopy reported failure for %%F (exit code !RC!) + set "ANY_FAIL=1" + ) + + echo.>>"%LOG_FILE%" + + :continue +) + +echo ============================================================ +echo Sync finished. +echo Review log for removed files marked as: +echo *EXTRA File +echo *EXTRA Dir +echo. +echo Log file: +echo %LOG_FILE% +echo ============================================================ + +if "%ANY_FAIL%"=="1" ( + echo Log file: + echo %LOG_FILE% + echo. + pause + exit /b 8 +) +pause +exit /b 0