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

How can I join two or more text files together

Posted on 2014-10-30
Last Modified: 2014-10-30
I would like to join two or more text files together however I need to ensure there is a blank line between the data which was found in each file.
Question by:100questions
  • 2
  • 2
  • 2
LVL 10

Accepted Solution

JoeKlimis earned 500 total points
ID: 40413528
This is a powershell solution

where data.txt and data1.txt are the two files to be joined into the results file r.txt

  $(gc data.txt)  +"`n "+ $(gc data1.txt) | Out-File r.txt

Open in new window

LVL 43

Expert Comment

by:Steve Knight
ID: 40413581
In batch one way would be something like this - will take all .txt files in c:\yourdir:

@echo off
cd /d "c:\yourdir"
(for /f %%a in ('dir /b /a-d *.txt') do (
 type "%%~a"
)) > outfile.txt

Open in new window


Author Comment

ID: 40413595
@JoeKlimis - Thanks Joe, this works well.  How would I specify the path of each input file.
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

LVL 10

Expert Comment

ID: 40413639
I have included the file paths

$(gc c:\temp\data.txt)  +"`n "+ $(gc d:\temp2\data1.txt) | Out-File e:\temp3\r.txt

Open in new window

you can always use wildcards too (*) as follows

$(gc c:\temp\data*.txt)  +"`n "+ $(gc d:\temp2\A*.txt) | Out-File e:\temp3\r.txt

Open in new window


Author Closing Comment

ID: 40413850
Excellent, works well.
LVL 43

Expert Comment

by:Steve Knight
ID: 40413911
Could you post in area relating to language wanted only another time please to save wasting time?

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

Suggested Solutions

Title # Comments Views Activity
VMWare Calculate number of processors 10 61
How to implement an additional command 16 40
Start-VM 3 18
Copy 20 files at a time from drive G to drive H 10 47
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Set OWA language and time zone in Exchange for individuals, all users or per database.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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