Reputation: 111
I need a batch files to delete more files which does not contain within them a series of words.
Path Root of folder
D:\Programmi Installati\Openvpn Portable\data\log
File have different name but end with .log
123.log
abc.log
home.log
I need to delete all files that NOT contain in the source "Successfully Connected", the files have many lines.
This bat file must read inside the files .log saved in the folder and delete all files that NOT contain the phrase "Successfully Connected",
Note: All files have several lines of text inside them and contains simple text.
Upvotes: 1
Views: 417
Reputation: 57252
@echo off
pushd "D:\Programmi Installati\Openvpn Portable\data\log"
for %%# in (*.log) do (
find /i "Succefully Connected" "%%~f#" >nu 2>nul||(
del /q /f "%%~f#" >nul 2>nul
)
)
popd
Upvotes: 1