I wrote this Windows Command script a long time ago to get rid of extraneous backup files and abandoned saved variables.
Code:
@echo off
pushd "C:\Program Files (x86)\World of Warcraft\WTF\Account"
del /s *.bak
del /s *.old
for /d %%i in (*) do (
if exist %%i\SavedVariables\ (
echo Account: %%i
for %%j in ("%%i\SavedVariables\*.lua") do (
echo %%~nj | findstr /r /i "^Blizzard_" > nul
if errorlevel 1 (
echo GlobalSV: %%~nj
if not exist ..\..\Interface\AddOns\%%~nj\ (
echo Delete: %%~nj
del "%%j"
)
)
)
for /d %%j in ("%%i\*") do (
for /d %%k in ("%%j\*") do (
echo Character: %%k
for %%l in ("%%k\SavedVariables\*.lua") do (
echo %%~nl | findstr /r /i "^Blizzard_" > nul
if errorlevel 1 (
echo CharSV: %%~nl
if not exist ..\..\Interface\AddOns\%%~nl\ (
echo Delete: %%~nl
del "%%l"
)
)
)
)
)
)
)
popd
pause
It scans through the SavedVar directories and checks if each Lua file has a matching addon folder name. If it doesn't, the file is deleted.
Make sure the initial
pushd is pointing to your WoW account directory. The path I used is the default.