?
Solved

Concatenating multiple text files into one file

Posted on 2011-09-26
3
Medium Priority
?
626 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

777 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