Solved

How can I join two or more text files together

Posted on 2014-10-30
6
124 Views
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.
0
Comment
Question by:100questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
JoeKlimis earned 500 total points
ID: 40413528
Hi
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

0
 
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"
 echo.
)) > outfile.txt

Open in new window

Steve
0
 

Author Comment

by:100questions
ID: 40413595
@JoeKlimis - Thanks Joe, this works well.  How would I specify the path of each input file.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:JoeKlimis
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

0
 

Author Closing Comment

by:100questions
ID: 40413850
Excellent, works well.
0
 
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?
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now