1.

Solve : Remove lines from text files in a directory (keeping original file name)?

Answer»

Can someone help me? I have a directory full of html files, in the html files, I want to remove all LINES that have "xxx

I can run the following command and it prints my output correct, but I don't know how to keep the original filename.

findstr /b /v /i /c:"
I don't want to have to run this for every file like

findstr /b /v /i /c:"> copy_fixed.htmThis is untested:

Code: [Select]ECHO off
for /f "delims=" %%a in ('dir *.htm /b /a-d ') do findstr /b /v /i /c:"<LI" "%%a" > "%%a.tmp" & move "%%a.tmp" "%%a"
  Quote from: foxidrive on April 29, 2014, 10:54:01 AM

This is untested:

Code: [Select]echo off
for /f "delims=" %%a in ('dir *.htm /b /a-d ') do findstr /b /v /i /c:"<li" "%%a" > "%%a.tmp" & move "%%a.tmp" "%%a"
 

THANK you... This was right... I was running it in command prompt - so i changed %%a to %a. I didn't want to get prompted on the moving of files, so I added a /Y to the move command... THank you so MUCH.
Final command:
Code: [Select]echo off
for /f "delims=" %a in ('dir *.htm /b /a-d ') do findstr /v /i /c:"<li" "%a" > "%a.tmp" & move /Y "%a.tmp" "%a"


Discussion

No Comment Found