1.

Solve : Prevent exclamation marks from going away?

Answer»

What I am trying to do is use a FOR loop to send the contents of one batch file (STARTING at the 37 line) into another. To do this, I use this code:

for /f "skip=36 delims=" %%Z in (batchfile.bat) do echo %%Z >> newbatchfile.bat

However, it removes exclamation marks (which as you may know, can be critically important in batch files). Can someone help me prevent this from removing the exclamation marks?

EDIT: I tried DISABLING delayed expansion and it worked! Thanks anyway!you can use more
Code: [Select]more +36 file >newfile
Quote from: ghostdog74 on July 30, 2010, 10:07:10 PM

you can use more
Code: [Select]more +36 file >newfile

I noticed that the help for more says

Code: [Select]   +n      Start displaying the first file at line n
in fact more +n skips n lines, and starts displaying the file at line n+1.

Code: [Select]del testfile.txt & for /L %%N in (1,1,40) do echo This is line %%N>>testfile.txt
echo (1) FOR /f "skip=36"
for /f "skip=36 delims=" %%Z in (testfile.txt) do echo %%Z
echo (2) more +36
more +36 testfile.txt

Code: [Select](1) FOR /f "skip=36"
This is line 37
This is line 38
This is line 39
This is line 40
(2) more +36
This is line 37
This is line 38
This is line 39
This is line 40







Discussion

No Comment Found