?
Solved

Combine text files and maintain format

Posted on 2010-11-10
7
Medium Priority
?
434 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 1000 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
Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

 
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 1000 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 56

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

800 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