Solved

Combine text files and maintain format

Posted on 2010-11-10
7
418 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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

21 Experts available now in Live!

Get 1:1 Help Now