Solved

Combine text files and maintain format

Posted on 2010-11-10
7
423 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
ID: 34106455
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
ID: 34106483
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
ID: 34106502
Another option might be:

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


0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 33

Expert Comment

by:knightEknight
ID: 34106518
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
ID: 34106693
@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 53

Expert Comment

by:Bill Prew
ID: 34107221
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
ID: 34107387
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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