Merge Multiple Text files into One Text File

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Vinez
Posts: 4
Joined: Wed Jul 02, 2008 1:41 pm

Merge Multiple Text files into One Text File

Post by Vinez »

Does anyone know if it is possible to automate the process of merging three text files into one textfile each week? This will be a recurring process. For example, I need to submit a Positive Pay reconciliation to the bank each week in one text file. Currently I have 3 separate text files that consist of a Header, Details, and Trailer. This is a Fixed Width Text files that need to be combined. Can anyone help? Thanks.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

1. Could make a macro using File/Open, then Edit/Insert/Files or FileName. then File/SaveAs. Would need to always have the same filenames for the macro to work.

2. Could create a batch file to append the files with Xcopy and call the batch file using Tools. Could use wildcards for filenames if different each week.

May need to add extra steps to remove lines with extra header/footers. That could be done on the final combined file with a RegEx
Hope this was helpful.............good luck,
Bob
Vinez
Posts: 4
Joined: Wed Jul 02, 2008 1:41 pm

Thanks

Post by Vinez »

Thank you Bob. I was able to do the batch file and it worked.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

And it only took less than three minutes!
Hope this was helpful.............good luck,
Bob
Vinez
Posts: 4
Joined: Wed Jul 02, 2008 1:41 pm

FYI

Post by Vinez »

I actually went to expert exchange and received this answer to create a .bat file

@echo off
cls
set file1=BOAHeader.txt

set file2=BOADetails.txt

set file3=BOATrailer.txt

set dest=BOAPPOutput.txt

type %file1% > %dest%
type %file2% >> %dest%
type %file3% >> %dest%

I did this earlier. However, thanks again for your response.
User avatar
Alan-LB
Posts: 22
Joined: Sat Feb 02, 2008 4:29 am
Location: Junee, NSW, Australia

Post by Alan-LB »

What about making a file called "MyCopy.bat" containing -

@echo off
copy %1 + %2 + %3 %4


Then call
MyCopy BOAHeader.txt BOADetails.txt BOATrailer.txt BOAPPOutput

Alan
Vinez
Posts: 4
Joined: Wed Jul 02, 2008 1:41 pm

Merge Multiple Text files into One Text File

Post by Vinez »

Thank you, I will try that.
Post Reply