Concatenate a lot of txt file content and skip the first line in the batch file

I want to create a batch file Batch to concatenate a text file with the extension ".mf" However, each file contains the date on the first line that I want in the final output file. Please advice on how do I get rid of the date string from each file when merging into one big txt file.

I used the following command to merge txt files for a batch file.

copy *.mf big.one
ren big.one filename.mf

      

Example:

2013218;
a
b
c
d

      

-

2013218;
u
v
w
x
y
z

      

The output should be as follows:

2013218;
a
b
c
d
u
v
w
x
y
z

      

Sorting doesn't matter.

+3


source to share


1 answer


@echo off
del big.one 2> NUL
for %%f in (*.mf) do (
   if not exist big.one (
      copy "%%f" big.one
   ) else (
      for /F  "usebackq skip=1 delims=" %%a in ("%%f") do (
         echo %%a>> big.one
      )
   )
)
set /P fileDate=< big.one
ren big.one filename_%fileDate:~0,-1%.mf

      



This solution does not save blank lines from the second file; this can be corrected if necessary.

+6


source







All Articles