1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Combining 30 text files into single text file

Discussion in 'Business Applications' started by vinwin06, Jul 31, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. vinwin06

    vinwin06 Thread Starter

    Joined:
    Jul 28, 2010
    Messages:
    413
    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!!!
     
  2. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    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.
     
  3. vinwin06

    vinwin06 Thread Starter

    Joined:
    Jul 28, 2010
    Messages:
    413
    can you tell me what coding i can use for this
     
  4. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    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)?
     
  5. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    If the answer to the first question is yes, and the order is irrelevant, use the copy command.

    Code:
    pushd [I]Directory holding files[/I]
    Copy /A *.txt mergedfile.txt
    
     
  6. vinwin06

    vinwin06 Thread Starter

    Joined:
    Jul 28, 2010
    Messages:
    413
    Im getting a error message saying that "the system cannot able to find the specified files"
     
  7. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    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.
     
  8. vinwin06

    vinwin06 Thread Starter

    Joined:
    Jul 28, 2010
    Messages:
    413
    Hi,

    Can you please tell me what kind of code i can use for this issue....??
     
  9. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    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?
     
  10. vinwin06

    vinwin06 Thread Starter

    Joined:
    Jul 28, 2010
    Messages:
    413
    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:

  11. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,946
    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
     
  12. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,946
    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
     
  13. vinwin06

    vinwin06 Thread Starter

    Joined:
    Jul 28, 2010
    Messages:
    413
    Can you help me in vba codes??
     
  14. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,946
    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 ???
     
  15. vinwin06

    vinwin06 Thread Starter

    Joined:
    Jul 28, 2010
    Messages:
    413
    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...
     
  16. Sponsor

As Seen On
As Seen On...

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.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/939710