Answer the question
In order to leave comments, you need to log in
How to write a batch file that deletes files that have a line with the given content in the given directory?
Hello, I need your help.
Answer the question
In order to leave comments, you need to log in
help: https://ss64.com/nt/
hint from KO:
you will need a command that searches for lines in files (one of)
you will need a command that executes another command for all the results of the third command
you will need a command that deletes files ( haha, sorry).
Or take powershell (stop digging out the stewardess torturing cmd )
Both scripts will turn out to be quite simple, both on Posh and on cmd
More or less like this:
@echo off
chcp 1251 1>nul
set "find_str=search string"
set "search_dir=c:\temp"
for %%a in (%search_dir%) do (
findstr /C:"%find_str%" "%%~a" 1>nul 2>&1 && del /f /q "%%~a"
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question