@echo off
:: Set Silent to 1 to always run silently...
set silent=0
:: Analyze any potential argument...
if %silent%==1 goto skipbs
if %1.==. goto bs
if %1==s goto set_silent
if %1==silent goto set_silent
if %1==-s goto set_silent
if %1==-silent goto set_silent
if %1==/s goto set_silent
if %1==/silent goto set_silent
if %1==h goto help
if %1==help goto help
if %1==-h goto help
if %1==-help goto help
if %1==/h goto help
if %1==/help goto help
goto bs
:set_silent
set silent=1
goto skipbs
:bs
cls
@echo. +---------------------------------------------.
@echo. : :
@echo. : Civilization IV - Clear Caches Batch Script :
@echo. : Script by: krille @ CivFanatics.com, 2008 :
@echo. : :
@echo. : Description: Clears the game cache of Civ4 :
@echo. : original/vanilla, Warlords and BtS. :
@echo. : :
@echo. : Params: -s for silent mode, -h for help. :
@echo. : :
@echo. '---------------------------------------------'
@echo.
@echo. The following directories will be deleted:
@echo.
@echo. %APPDATA%\...
@echo. My Games\Sid Meier's Civilization 4\cache
@echo. My Games\Walords\cache
@echo. My Games\Beyond the Sword\cache
@echo.
@echo. %USERPROFILE%\...
@echo. Local Settings\Application Data\My Games\Sid Meier's Civilization 4\cache
@echo. Local Settings\Application Data\My Games\Walords\cache
@echo. Local Settings\Application Data\My Games\Beyond the Sword\cache
@echo.
set /p input= Are you sure? Enter 'y' to confirm. Anything else aborts. y/n:
if %input%.==. goto abort
if %input%==y goto skipbs
if %input%==Y goto skipbs
goto abort
@echo.
@echo.
:skipbs
@echo.
rmdir "%USERPROFILE%\Local Settings\Application Data\My Games\Sid Meier's Civilization 4\cache\" /s /q
rmdir "%USERPROFILE%\Local Settings\Application Data\My Games\Warlords\cache\" /s /q
rmdir "%USERPROFILE%\Local Settings\Application Data\My Games\Beyond the Sword\cache\" /s /q
rmdir "%APPDATA%\My Games\Sid Meier's Civilization 4\cache\" /s /q
rmdir "%APPDATA%\Walords\cache\" /s /q
rmdir "%APPDATA%\Beyond the Sword\cache\" /s /q
@echo.
if %silent%==1 goto silent_end
@echo.
@echo Up to six 'errors' above is perfectly normal.
@echo (A directory can't be deleted if it doesn't exist.)
::cls
@echo.
@echo All Civilization 4 caches should now be cleared.
@echo (Including Warlords and BtS caches).
goto end
:help
@echo.
@echo.
@echo HELP
@echo.
@echo Use -s or -silent or s or silent for silent operation.
@echo.
goto silent_end
:abort
cls
@echo.
@echo Operation aborted.
:end
@echo.
@echo.
PAUSE
:silent_end