Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Combine text files and maintain format

Posted on 2010-11-10
7
Medium Priority
?
442 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 58

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

609 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