Discussion Locked

NT Batchfile

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Im running an NT batchfile to parse a text document looking for certain lines and sending them to another document. In the first document some of the lines have carats (^) and of course these wont parse to the second document. Ive been assured that without the carats the file wont work properly. Here is an example of the text file:

^FO140,25^A0N,18,18^CI0^FN2^FS
^FO270,25^A0N,18,18^CI0^FN3^FS
^FO210,120^A0B,18,18^CI0^FN8^FS
^FO010,005^A0N,18,18^CI0^FN10^FS

Is there any way to get the carats from the first document to the second document?

5 replies

by timthetoolman

Hi,

Yes it is possible. I dont know exactly how you're parsing the file and outputting to the new document, but if you were using a for statement to parse the file in the first place and tokenise to components based on the carats

For example...

E:\Documents and Settings\Tim Medhurst>type temp.txt
^FO140,25^A0N,18,18^CI0^FN2^FS
^FO270,25^A0N,18,18^CI0^FN3^FS
^FO210,120^A0B,18,18^CI0^FN8^FS
^FO010,005^A0N,18,18^CI0^FN10^FS

E:\Documents and Settings\Tim Medhurst>for /f "tokens=1,2,3,4,5,6" %i in (temp.t
xt) do echo %i %j %k %l %m %n >> temp2.txt

E:\Documents and Settings\Tim Medhurst>echo ^FO140,25^A0N,18,18^CI0^FN2^FS
1>>temp2.txt

E:\Documents and Settings\Tim Medhurst>echo ^FO270,25^A0N,18,18^CI0^FN3^FS
1>>temp2.txt

E:\Documents and Settings\Tim Medhurst>echo ^FO210,120^A0B,18,18^CI0^FN8^FS
1>>temp2.txt

E:\Documents and Settings\Tim Medhurst>echo ^FO010,005^A0N,18,18^CI0^FN10^FS
1>>temp2.txt

E:\Documents and Settings\Tim Medhurst>type temp2.txt
^FO140,25^A0N,18,18^CI0^FN2^FS
^FO270,25^A0N,18,18^CI0^FN3^FS
^FO210,120^A0B,18,18^CI0^FN8^FS
^FO010,005^A0N,18,18^CI0^FN10^FS

Outputs the carats as expected. However if you need to output individual carats, then simply use a double caratFor example...

E:\Documents and Settings\Tim Medhurst>echo Text^Caret
TextCaret

E:\Documents and Settings\Tim Medhurst>echo Text^^Caret
Text^Caret

One of those solutions should help. If not, post back here a few more specifics so I can help you.

Cheers,
Tim.

by fenaikh

Hi
Just anote :

in the line says above:
E:\Documents and Settings\TimMedhurst>for /f "tokens=1,2,3,4,5,6" %i in (temp.t
xt) do echo %i %j %k %l %m %n >> temp2.txt

the for statment is should be in one line only for the "for" to be executed correctry.

Good luck

Mohamed

This discussion is closed to new replies.