?
Solved

Concatenating multiple text files into one file

Posted on 2011-09-26
3
Medium Priority
?
627 Views
Last Modified: 2012-05-12
If I have multiple text files in a folder (Folder A).  Does any one know through Windows scripting how to concatenate them into one file without maually cut and pasting?

Example
Text1.txt
Text2.txt
Text3.txt                         to                     Text4.text (which has all the files)
0
Comment
Question by:morinia
[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 Comments
 
LVL 18

Accepted Solution

by:
Gary Davis earned 2000 total points
ID: 36613688
You could use the command-line copy command:

   copy Text1.txt + Text2.txt + Text3.txt  Text4.text

Gary Davis
0
 
LVL 4

Expert Comment

by:klodefactor
ID: 36623383
I typically don't type spaces around the plus signs, to make it easier to see where the target file name starts.

If there's any chance of non-ASCII characters in one of the files, use the /b option for the copy command:
copy/b Text1.txt+Text2.txt+Text3.txt Text4.text.
If any file name contains one or more spaces, remember to surround the name with double quote characters ("):
copy/b "file name one.txt"+Text2.txt+Text3.txt Text4.text.
--klodefactor
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36707747
You can also do

copy c:\someotherdir\*.txt C:\alldir\all.txt
(as otherwise all.txt would be included in the output!)

or
type c:\somedir\*.txt > c:\alldir\all.txt

or if you want a little header saying which file it is:

find /v "something-not-in-any-file zxzxcvbz" *.txt > all.txt
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
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…

649 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