Ivan Loguz
Ivan Loguz

Reputation: 91

Batch file to merge all txt files in folder on beginning and end of each txt file

Hi guys I have folder with large number of txt files.

start.txt
end.txt
text1.txt
text2.txt
text3.txt
...

I need to create batch file/command who will merge files like this:

start.txt -> text1.txt -> end.txt to text1.txt

start.txt -> text2.txt -> end.txt to text2.txt

I can put start.txt and end.txt outside folder, so its easier to work with.

So my new text1.txt will look like:

text1.txt

start.txt
text1.txt
end.txt

And so on..

Upvotes: 0

Views: 139

Answers (1)

Joey
Joey

Reputation: 354386

You don't even need a batch file for that:

for %F in (*.txt) do copy ..\start.txt+%F+..\end.txt ..\new_%F

If used in a batch file you need to double the %:

for %%F in (*.txt) do copy ..\start.txt+%%F+..\end.txt ..\new_%%F

Upvotes: 2

Related Questions