user3245536
user3245536

Reputation: 1

For DelayedExpansion Variables Values get stored

I'll try my best to explain my problem. I want to rewrite a file that contains:

If "!Var!" ....

I am rewriting it in a temp file in a for-loop with DelayedExpansion Enabled (I need it enabled to set the !Var! value in the loop), but as soon as he get to the line that cantains that text shown above it writes:

If "Value of Var" ....

So I tried to Disable and then Enable the Expansion while I run ((echo %%a)>>"Temp.File"), but then it says maximum SetLocal reached.

Please help

Rudi

Upvotes: 0

Views: 86

Answers (1)

MC ND
MC ND

Reputation: 70923

(for /f "tokens=1,* delims=:" %%a in ('findstr /n "^" "%inputFile%"') do (
  if %%a lss %begin% ( echo(%%b
  ) else if %%a gtr %end% echo(%%b
)) > "%tempFile%"

Use findstr to numerate the lines of the input file. Numbers are separated from content via tokens and delimiters clauses of for command. If number is out of range, echo the line content. All output is redirected to temporary file

Upvotes: 1

Related Questions