1

The code I found allows me to add text to every line of a txt file, but I would like to edit only the lines that begin with HTTP

@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
echo ^%%a^|User-Agent=Vlc>>output.txt
)
Tuk72
  • 13
  • 2
  • Does this answer your question? [Batch file if string starts by](https://stackoverflow.com/questions/36228474/batch-file-if-string-starts-by) – Melebius May 12 '20 at 06:30

1 Answers1

0

Replace your echo line inside the for loop with the following:

set _line=%%a
set _suffix=
if "!_line:~0,4!"=="HTTP" set _suffix=^|User-Agent=Vlc
echo %%a!_suffix!>>output.txt
rotemp
  • 61
  • 7
  • After writing HTTP in lowercase it works perfectly, I didn't think it was case sensitive, thanks! – Tuk72 May 13 '20 at 19:42