Solved

Combine text files and maintain format

Posted on 2010-11-10
7
417 Views
Last Modified: 2012-05-10
How could I append 70 files into one file and maintain the current file layout. The current file format is .txt.
0
Comment
Question by:Laballa1
  • 3
  • 3
7 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 250 total points
Comment Utility
copy/y  file1.txt + file2.txt
 copy/y  file1.txt + file3.txt
 copy/y  file1.txt + file4.txt
 copy/y  file1.txt + file5.txt
...
 copy/y  file1.txt + fileN.txt
 

:at the end of all the above, file1 will have its original content, plus the content of all the other files.
0
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
actually, you may be better off doing it like this:

copy/y  file1.txt  +  file2.txt  +  file3.txt  +  file4.txt  +  ...  + fileN.txt

0
 
LVL 26

Expert Comment

by:pony10us
Comment Utility
Another option might be:

for /f %%a IN ('dir /b *.txt') do (
type %%a >> all70.txt
)


0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
still another option, which will preserve all the original files ... it is similar, just specify a destination file at the end:

   copy/y  file1.txt  +  file2.txt  +  file3.txt  +  file4.txt  +  ...  + fileN.txt    RESULT.txt

(note there is no + before the result filename)
0
 
LVL 26

Assisted Solution

by:pony10us
pony10us earned 250 total points
Comment Utility
@knightEknight

The disadvantage to using your methods that I see is the number of files involved:
1. It would be easy to make a typo while listing 70 files
2. Wouldn't you come up against the character limit of a command (126 characters)

If this is to be a re-useable command you would have to alter it each time that the number of files changed or the name changes.

Just some observations to consider.
0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
What do the TXT files look like, and what do you mean by "maintain the current format".

Isn't the simplest way to combine them to just do:

copy *.txt c:\temp\newfile.txt

~bp
0
 
LVL 26

Expert Comment

by:pony10us
Comment Utility
I was thinking of the concerns that I mentioned to knightEknight and then reading billprew's response and it flagged a concern to using his and mine that I hadn't thought of.  If there are more .txt files in the same folder that you do not want combined then our methods wouldn't work either.

I suppose it comes down to which method would work the best for the situation.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now