|
Answer» Hello, I'm trying to find a script that will search for certain text in a file, and if found, delete it. Something like this, but I can't get it to work for some reason.
@ECHO off for /F"delims=;" %%a in ('findstr /m /i "alldata" %userprofile%\Cookies\*.txt') do ( @echo %%a rem del %%a ) This may help:
Code: [Select]@echo off for /f "tokens=* delims=" %%i in ('dir /a:-d /b /s %userprofile%\Cookies\*.txt') do ( findstr /m /i "alldata" "%%i" if not errorlevel 1 rem del %%i )
If the console output looks OK, remove the rem instruction from the if statement to actually delete the files.
Good luck. Thank you for your reply. Unfortunately, I get a MESSAGE that says: "The system cannot find the PATH specified."Double check that path. On my Win7, c:\%userprofile\Cookies is a junction and points to C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Cookies and the %user%profile%\cookies folder is hidden and flagged as a system folder.
Try hardcoding the cookie path as: C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Cookies
Thank you for the reply. I have to look further into this issue because windows blocks the folder by default. Looks like I have to find another alternative to removing cookies for my jobs website another way without removing the entire cookies. Thank you for your help SideWinder, definetely appreciate the FAST response.
|