DOS batch removing last empty line in output TXT file -
The following code lists file names in one directory:
for / f The result is%% (In 'dir / b D: \ folder * * * .xml') (%% A & gt; & gt; lines.txt in a line)
(With line numbers):
1 86002_2014_1.xml 2 86014_2014_1.xml 3 86014_2014_2.xml 4 86016_2014_1.xml 5 86017_2014_1.xml 6
with me There is always an empty line
your The output of the command creates a set of lines, all have a CR Has been finished with Lf pair. This is normal behavior .... text ... 0x0D0x0A
, standard line termination in windows.
So, in your case, if there is no other line or not, then just a point view. But, for you, the last CRF is not desired, all the rows ( & lt; nul set / p) = Text "
) is required to discard the finished CRLF and assign them a CRLF ( echo
)
< Code> set "first =" & lt; nul (for / f "delims ="% (if previously defined (echo ()) other (set "first = 1") set / p ". = %% a "))> (% Dir / b D: \ folder * * .xml 'Lines.txt
Comments
Post a Comment