Skip to content

Instantly share code, notes, and snippets.

@AaronTrotter
Last active May 18, 2020 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AaronTrotter/dc8cce655c6a61d77826290c40b7e313 to your computer and use it in GitHub Desktop.
Save AaronTrotter/dc8cce655c6a61d77826290c40b7e313 to your computer and use it in GitHub Desktop.
Clear UE4 Binaries, Intermediate and Regenerate VS
@ECHO OFF
set dt=%DATE:~6,4%.%DATE:~3,2%.%DATE:~0,2%-%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%
set dtstamp=%dt: =0%
set projectPath=""
set projectName=""
setlocal enableDelayedExpansion
set /a ID=0
echo "removing cache"
echo "--searching root"
if EXIST Binaries (
echo "----cleared Binaries"
RD /S /Q Binaries
)
if EXIST Intermediate (
echo "----cleared Intermediate"
RD /S /Q Intermediate
)
for /D %%i in (Plugins\*) do (
echo "--searching %%i"
if EXIST "%%i\Binaries" (
echo "----cleared Binaries"
RD /S /Q "%%i\Binaries"
)
if EXIST "%%i\Intermediate" (
echo "----cleared Intermediate"
RD /S /Q "%%i\Intermediate"
)
)
echo "Locating Engine"
if not EXIST "UE4ClearCacheEnginePath.txt" (
set /p cacheEnginePath="Engine Path: "
)
if defined cacheEnginePath (
echo "Creating Cache Engine Path"
echo %cacheEnginePath%> UE4ClearCacheEnginePath.txt
)
for /f "delims=" %%i in ('type UE4ClearCacheEnginePath.txt') do set enginePath=!enginePath!%%i
if not EXIST "%enginePath%" (
echo "%enginePath% is not a valid path"
pause
exit
) else (
echo "Engine Found: %enginePath%"
)
set buildToolPath=%enginePath%/Engine/Binaries/DotNET/UnrealBuildTool.exe
echo "searching root for UProject"
for /f "delims=" %%G in ('dir *.uproject /b') do (
set filename[!ID!]=%%~G
set /a ID+=1
set projectName = %%~G
set projectPath=%CD%\%%~G
)
@echo "--%ID% UProject(s) Found"
set logPath=%CD%\Saved\Logs\UnrealVersionSelector-%dtstamp%.log
if %ID% GTR 0 (
echo "--rebuilding projectName"
echo "buildToolPath: %buildToolPath%"
echo "logPath: %logPath%"
start "" "%buildToolPath%" -projectfiles -project="%projectPath%" -game -rocket -progress -log="%logPath%"
)
endlocal
TIMEOUT /T 10
exit
@AaronTrotter
Copy link
Author

Place this in root directory.
It will ask you for the engine path once. This is required to regenerate Visual Studio project. It will create a file called UE4ClearCacheEnginePath in the root directory. Exclude it from git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment