user3273534
user3273534

Reputation: 55

Replace string % with %% using batch file

I have a text like below in input.txt file.

sdf%5Ddfssdsd%2Ddfdf

I would like to replace "%" with "%%" in the output file. so the text should look like

sdf%%5Ddfssdsd%%2Ddfdf

Appreciate your help!!

Upvotes: 2

Views: 86

Answers (1)

James L.
James L.

Reputation: 9451

@echo off

setlocal ENABLEDELAYEDEXPANSION

for /f "tokens=1* delims=" %%i in (input.txt) do (
  set _line=%%i
  set _line=!_line:%%=%%%%!
  echo !_line! >> output.txt
)

endlocal

Upvotes: 2

Related Questions