Page 1 of 1
Merge Multiple Text files into One Text File
Posted: Wed Jul 02, 2008 1:48 pm
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.
Posted: Wed Jul 02, 2008 8:38 pm
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
Thanks
Posted: Wed Jul 02, 2008 8:41 pm
by Vinez
Thank you Bob. I was able to do the batch file and it worked.
Posted: Wed Jul 02, 2008 8:43 pm
by Bob Hansen
And it only took less than three minutes!
FYI
Posted: Wed Jul 02, 2008 8:47 pm
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.
Posted: Thu Jul 03, 2008 2:21 am
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
Merge Multiple Text files into One Text File
Posted: Thu Jul 03, 2008 12:00 pm
by Vinez
Thank you, I will try that.