cleanup.bat 1.72 KB
@echo off
rem Clean up old local logs (logs\) and old result folders (edge_data\) of THIS StoreEdge folder by hand.
rem Double-click it. It asks for administrator rights (the service writes these files), shows what would be deleted
rem and asks before deleting anything. The cloud console can do the same remotely (Client -> devices -> clean up).
rem Never deleted: today's files, run\ (login state, data not yet sent to the cloud), config.ini and its backups.
rem Minimum kept: logs 30 days, results 3 days (smaller numbers are raised to these).
rem   cleanup.bat                         use the keep days from the cloud console (runtime settings)
rem   cleanup.bat --logs-days 365 --data-days 90
rem   cleanup.bat --yes                   do not ask
setlocal
net session >nul 2>&1
if not errorlevel 1 goto admin
echo Asking for administrator rights (the service owns the log files) ...
if "%~1"=="" goto elevate_noargs
powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -ArgumentList '%*' -Verb RunAs"
goto elevated
:elevate_noargs
powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
:elevated
if not errorlevel 1 exit /b 0
echo [ERROR] Could not get administrator rights. Right-click cleanup.bat and choose "Run as administrator".
pause
exit /b 1

:admin
cd /d "%~dp0"
if exist "python38\python.exe" goto run
echo [ERROR] python38 folder not found in %~dp0 . Install StoreEdge first (install.bat).
pause
exit /b 3
:run
set PYTHONNOUSERSITE=1
rem one block: a remote update may replace this file while it runs
setlocal EnableDelayedExpansion
(
  python38\python.exe main.py cleanup %*
  set RC=!errorlevel!
  echo.
  echo ===== exit code !RC!  ^(0=ok 2=failed 3=config error^)   folder: %~dp0 =====
  pause
  exit /b !RC!
)