Creating a master file

Hi guys,
I hope you are well and can help.

I have many text files, all with the same  format, that contain, as part of their file names, "summary_sorted.txt".
For example, summary_sorted_a_.txt,  summary_sorted_b.txt, summary_sorted_c.txt etc etc.

The format of each of these files is as follows:

--------------------------------------------------------------------------------------------------- summary_sorted_a.txt
abalone, adversary, aeroplane, at the park;

--------------------------------------------------------------------------------------------------- summary_sorted_b.txt
bat, benign, bipartisan;

I'd like to produce a script that will....

Examine each summary_sorted.txt file.
For each file examined, treat each file examined as 1 line, and copy its entire contents to a new file called master.txt. and
then add a blank line after its pasted contents, before the script goes on to look at the next summary_sorted.txt file.

As an example of what a master.txt file would look like based on the above, would be:

--------------------------------------------------------------------------------------------------- master.txt
abalone, adversary, aeroplane, at the park;

bat, benign, bipartisan;

Any help greatly appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
for /f "tokens=*" %%a in ('dir /b /on summary_sorted_?.txt') do (
  echo %%a>>master.txt

Open in new window

Simon336697Author Commented:
Hi NVIT, thanks for this.

Your solution I thank you for, but its not doing exactly what I want.

With your code, it is creating a master.txt file (which is good), but the contents just contain the file name of each of the files instead of its contents.

Your code does the following..

============================================= master.txt



-------------------------------------------------------------------------------------------------- master.txt

abalone,adversary,aeroplane,at the park;   (this is the contents of summary_sorted_a.txt)

bat, benign, bipartisan; (this is the contents of summary_sorted_b.txt)
Bill PrewIT / Software Engineering ConsultantCommented:
Try this:

@echo off
setlocal EnableDelayedExpansion

for /f "tokens=*" %%a in ('dir /b /on summary_sorted_?.txt') do (
  set /p line=<"%%~a"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Simon336697Author Commented:
Thanks Bill.
That did it.
Simon336697Author Commented:
Thanks to both you guys, you are great.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.