Solved

Concatenating multiple text files into one file

Posted on 2011-09-26
3
625 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

690 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