Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

Solved: Combining 30 text files into single text file


(!)

vinwin06's Avatar
vinwin06 vinwin06 is offline
Computer Specs
Member with 413 posts.
THREAD STARTER
 
Join Date: Jul 2010
Experience: Intermediate
31-Jul-2010, 10:47 AM #1
Smile Solved: Combining 30 text files into single text file
Hi,

I have 30 different files in the same path, but the name of the each file should be different, how i can combine all the files data into a single text file.

If there is any macro will help me solve this.

Thanks in advance!!!
Ent's Avatar
Ent   (Josiah) Ent is online now Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,217 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
31-Jul-2010, 10:57 AM #2
You could use a Macro, but VBA is more appropriate for working within the Office program. You would probably find it easier to use a batch script. Or if the merge is more complicated than stringing the end of one file to the start of another, use another programming environment.

Last edited by Ent; 31-Jul-2010 at 11:05 AM..
vinwin06's Avatar
vinwin06 vinwin06 is offline
Computer Specs
Member with 413 posts.
THREAD STARTER
 
Join Date: Jul 2010
Experience: Intermediate
31-Jul-2010, 11:44 AM #3
can you tell me what coding i can use for this
Ent's Avatar
Ent   (Josiah) Ent is online now Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,217 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
31-Jul-2010, 11:48 AM #4
Can you tell me what you want, in terms of
-Is it a simple question of sticking the files together one after the other?
-What order do you want the files put together (if significant)?
Ent's Avatar
Ent   (Josiah) Ent is online now Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,217 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
31-Jul-2010, 11:52 AM #5
If the answer to the first question is yes, and the order is irrelevant, use the copy command.

Code:
pushd Directory holding files
Copy /A *.txt mergedfile.txt
vinwin06's Avatar
vinwin06 vinwin06 is offline
Computer Specs
Member with 413 posts.
THREAD STARTER
 
Join Date: Jul 2010
Experience: Intermediate
31-Jul-2010, 03:15 PM #6
Im getting a error message saying that "the system cannot able to find the specified files"
Ent's Avatar
Ent   (Josiah) Ent is online now Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,217 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
31-Jul-2010, 04:19 PM #7
That code depends upon your 30 files having the extension .txt .

It's still the simplest and weakest solution though. If you can be a little more specific as to what you want, it will be possible to find a better one.
vinwin06's Avatar
vinwin06 vinwin06 is offline
Computer Specs
Member with 413 posts.
THREAD STARTER
 
Join Date: Jul 2010
Experience: Intermediate
01-Aug-2010, 09:59 AM #8
Hi,

Can you please tell me what kind of code i can use for this issue....??
Ent's Avatar
Ent   (Josiah) Ent is online now Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,217 posts.
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
01-Aug-2010, 10:12 AM #9
If you want I can probably write the program for you. However I really need more information as to what you are after.

What format are your text files in? How must they be organized in the merged file? Please attach a sample.
Do the files have to be in a specific order? What is the naming scheme for the files?
Do you want the final files to go into a text file as this thead indicates, or into Excel as your other one indicates?
Will / how often will the program have to be reused. Do you get a new set of files every week, or is this one off?
vinwin06's Avatar
vinwin06 vinwin06 is offline
Computer Specs
Member with 413 posts.
THREAD STARTER
 
Join Date: Jul 2010
Experience: Intermediate
01-Aug-2010, 10:22 AM #10
Hi,

Im attaching the sample file for your reference. The files are in the sequence of dates. The file name should be "BHN_DAILY_TXN_SEARS_042310". The final file should be in text format is better for me. Every day i will new files, but for every month i need to combine 30 files.
Attached Files
File Type: txt BHN_DAILY_TXN_KMART_BATCH_041610.txt (2.2 KB, 85 views)
Keebellah's Avatar
Keebellah   (Hans) Keebellah is offline Keebellah is a Trusted Advisor with special permissions. Keebellah has a Profile Picture
Computer Specs
Trusted Advisor with 5,185 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Advanced
01-Aug-2010, 05:00 PM #11
If the copy gives an error messgae I suggest the following:

Code:
pushd Directory holding files
Copy /A *.txt mergedfile.lst
ren mergedfile.lst mergedfile.txt
The error you get is probably that the file is tryoing to copy to itsseff
Keebellah's Avatar
Keebellah   (Hans) Keebellah is offline Keebellah is a Trusted Advisor with special permissions. Keebellah has a Profile Picture
Computer Specs
Trusted Advisor with 5,185 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Advanced
01-Aug-2010, 05:03 PM #12
Keep in mind that you have a leading file

01SAFEWAY.....

and a closing file

99SAFEWAY

I think that a vbs script is the best option, fast and simple
vinwin06's Avatar
vinwin06 vinwin06 is offline
Computer Specs
Member with 413 posts.
THREAD STARTER
 
Join Date: Jul 2010
Experience: Intermediate
01-Aug-2010, 05:13 PM #13
Can you help me in vba codes??
Keebellah's Avatar
Keebellah   (Hans) Keebellah is offline Keebellah is a Trusted Advisor with special permissions. Keebellah has a Profile Picture
Computer Specs
Trusted Advisor with 5,185 posts.
 
Join Date: Mar 2008
Location: Oegstgeest, The Netherlands
Experience: Advanced
02-Aug-2010, 01:11 AM #14
What is it exactly that you need?
You file:
Code:
01SAFEWAY DAILY RECON 2010041520100416                                                              
10600649030101004950020100415053958395800000000025001004150539580029210443                          
10600649030101867959720100415074055930500000000025000000014293050314000329                          
10600649030099819750520100415105216771400000000050001510535877140688003154                          
10600649030101462504020100415103433274300000000025001052649327430029000403                          
10600649030101236898120100415135743983200000000025001052858198320065000218                          
10600649030101170436820100415111041104100000000025001004151110410430651602                          
10600649030101662256520100415145901689700000000025001050988068970031000416                          
10600649030101188333720100415151020595300000000025001051528259530053008329                          
10600649030101860753120100415134445872500000000025000415038187250003001820                          
10600649030101701800320100415144400766900000000025000000005676690020000163                          
10600649030100926521620100415145819584500000000025000000014658450063000327                          
10600649030100923609220100415152243251800000000025000000014625180213000327                          
10600649030101601177720100415163054512400000000025000105000051240105001158                          
10600649030101604262420100415163025512200000000025000105000051220105001158                          
10600649030101601175120100415163039512300000000025000105000051230105001158                          
10600649030101696662420100415163011512100000000025000105000051210105001158                          
10600649030101222444020100415155404097400000000025001052138109740008003120                          
10600649030100483314120100415145611362400000000050000105210936240041000769                          
10600649030101566105120100415165418541800000000025001004151654180292953179                          
10600649030101170287520100415172908290800000000025001004151729080430648102                          
99SAFEWAY DAILY RECON 20100415201004160000002000000055000
Line 1 contains a header record 2010041520100416 that meabd apr 15 - apr 16

The last line 99SAFEWAY DAILY RECON 20100415201004160000002000000055000 is a closing record

apr-15 apr-16

Does it have to be in Excel?
You ask for a txt fle so it could also be one file containg all the files for the day?

The file location is that always the same?

Does the output file meet naming requirements: e.g. MERGED2010041520100416.txt ???

Last edited by Keebellah; 02-Aug-2010 at 01:12 AM.. Reason: info
vinwin06's Avatar
vinwin06 vinwin06 is offline
Computer Specs
Member with 413 posts.
THREAD STARTER
 
Join Date: Jul 2010
Experience: Intermediate
02-Aug-2010, 02:19 AM #15
I dont have any problem in to be in excel, but i want to merge all the files in the same file. This is the single file like this i have 30 files for every month i need to combine all the records into single file. The naming convention anything is ok for me...
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Title Thread Starter Forum Replies Last Post
Copying data from various text boxes to a .txt file tech.jk Software Development 2 15-Nov-2009 06:04 AM
Solved: Move multiple files into single folder Athought Windows Vista 3 13-Aug-2009 09:51 AM
Solved: Combining PDFs into a single file johnni All Other Software 3 15-Aug-2008 02:14 PM
turning files into a text doc? calibretto Business Applications 7 23-Oct-2005 09:05 PM
"Smoosh" text files into one big file cpuhack.com Business Applications 6 04-Dec-2002 03:37 PM

WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑