Batch Delete Folders That start a specific way

288 views Asked by At

I'm using a batch file to delete files in AppData, essentially I want to clear the cache in skype/Lync. I'm adapting stuff from old code from about a decade ago, so maybe what I'm doing is dumb for today.

what I have so far

@echo off
echo Clearing Lync cache...
If %errorlevel%==1 goto Error
if "%LOCALAPPDATA%"=="" Set LOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data
dir "%UserProfile%\AppData\Local\Microsoft\Office\16.0\Lync\sip_*" /b > list.txt
FOR /F "tokens=1" %%i in (list.txt) do del 

So this get's the sip_ info and populates it into a text file named list. I want to then delete all of the folders matching those names. rmdir doesn't seem to work, but i could be wrong

1

There are 1 answers

3
Hot Java On

nevermind, simple fix

cd %UserProfile%\AppData\Local\Microsoft\Office\16.0\Lync\
for /d /r %%i in (sip_*) do @rmdir /s "%%i"