83 lines
2.3 KiB
Batchfile
83 lines
2.3 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
REM ============================================================
|
|
REM Android project cleanup script (Windows .bat)
|
|
REM Recursively cleans ALL build outputs, Gradle cache, IDE files
|
|
REM under the directory where this script is located.
|
|
REM
|
|
REM Auto-discovers all projects - no hardcoded project list.
|
|
REM Safe: only deletes compiled outputs, never touches
|
|
REM third-party .so/.aar in jniLibs/, libs/, etc.
|
|
REM
|
|
REM No network required - purely file-level cleanup.
|
|
REM
|
|
REM Usage:
|
|
REM Double-click in Explorer, or
|
|
REM Run in CMD/PowerShell: clean_all.bat
|
|
REM ============================================================
|
|
|
|
cd /d "%~dp0"
|
|
|
|
set TOTAL_DELETED=0
|
|
|
|
echo ==============================================
|
|
echo Android Project Recursive Cleanup
|
|
echo Working dir: %cd%
|
|
echo ==============================================
|
|
echo.
|
|
|
|
REM ---- Directories to delete (recursive) ----
|
|
echo === Deleting directories ===
|
|
set DIRS=build .gradle .idea .cxx .externalNativeBuild .kotlin captures .navigation temp bin gen out
|
|
for %%A in (%DIRS%) do call :DelDir %%A
|
|
echo.
|
|
|
|
REM ---- Files to delete (recursive) ----
|
|
echo === Deleting files ===
|
|
set FILES=*.iml local.properties *.log *.hprof Thumbs.db .DS_Store *.tmp *.bak *~
|
|
for %%A in (%FILES%) do call :DelFile %%A
|
|
echo.
|
|
|
|
echo ==============================================
|
|
echo Done! Total items removed: %TOTAL_DELETED%
|
|
echo ==============================================
|
|
echo.
|
|
echo Tip: after cleanup, recompile with:
|
|
echo gradlew.bat assembleDebug
|
|
pause
|
|
exit /b 0
|
|
|
|
REM ============================================================
|
|
REM Subroutine: delete all matching directories
|
|
REM ============================================================
|
|
:DelDir
|
|
set COUNT=0
|
|
for /d /r . %%D in (%~1) do (
|
|
if exist "%%D" (
|
|
set /a COUNT+=1
|
|
rmdir /s /q "%%D" 2>nul
|
|
)
|
|
)
|
|
if %COUNT% gtr 0 (
|
|
echo %~1/ x %COUNT%
|
|
set /a TOTAL_DELETED+=%COUNT%
|
|
)
|
|
goto :eof
|
|
|
|
REM ============================================================
|
|
REM Subroutine: delete all matching files
|
|
REM ============================================================
|
|
:DelFile
|
|
set COUNT=0
|
|
for /r . %%F in (%~1) do (
|
|
if exist "%%F" (
|
|
set /a COUNT+=1
|
|
del /f /q "%%F" 2>nul
|
|
)
|
|
)
|
|
if %COUNT% gtr 0 (
|
|
echo %~1 x %COUNT%
|
|
set /a TOTAL_DELETED+=%COUNT%
|
|
)
|
|
goto :eof |