Avatar of Simon336697
Simon336697
Flag for Australia asked on

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.
Windows BatchVB ScriptScripting LanguagesShell Scripting

Avatar of undefined
Last Comment
Simon336697

8/22/2022 - Mon
SOLUTION
NVIT

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Simon336697

ASKER
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

summary_sorted_a.txt

summary_sorted_b.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)
ASKER CERTIFIED SOLUTION
Bill Prew

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Simon336697

ASKER
Thanks Bill.
That did it.
Simon336697

ASKER
Thanks to both you guys, you are great.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes