Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Combining files  (Read 2425 times)

0 Members and 1 Guest are viewing this topic.

Frank

    Topic Starter


    Intermediate

    Thanked: 3
    Combining files
    « on: June 11, 2009, 03:27:37 AM »
    I know that two files can be combined or added with:
    copy /b file.001 + file/002 outputfile

    This is o/k for a couple of file. I have 99 files file.001 to file.099 to combine. Is there a way place the above command in a loop to add them all together?
    Thanks

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: Combining files
      « Reply #1 on: June 11, 2009, 05:14:01 AM »
      you can do it the hard way. use wildcards
      Code: [Select]
      copy file.0* newfile
      copy file.1* anothernewfile
      then combine the 2 new files togther again.

      Frank

        Topic Starter


        Intermediate

        Thanked: 3
        Re: Combining files
        « Reply #2 on: June 11, 2009, 05:34:27 AM »
        Sometimes things turn out simple.
        My files are about 5Mb each and the total of 99 files turned out to be only 1K, Something is not right. I tried:
        copy /b file.0* newfile

        This gives the correct size. I am not sure what the /b switch does, but I hope the file contents is correct.
        Thanks

        gh0std0g74



          Apprentice

          Thanked: 37
          Re: Combining files
          « Reply #3 on: June 11, 2009, 05:46:43 AM »
          Sometimes things turn out simple.
          My files are about 5Mb each and the total of 99 files turned out to be only 1K, Something is not right. I tried:
          copy /b file.0* newfile

          This gives the correct size. I am not sure what the /b switch does, but I hope the file contents is correct.
          Thanks
          check copy /? for what /b does. also, you can make small files and test them out. then you can see what the final file looks like.

          Frank

            Topic Starter


            Intermediate

            Thanked: 3
            Re: Combining files
            « Reply #4 on: June 11, 2009, 05:49:41 AM »
            That's a good idea. I'll do that.
            Thanks

            ALAN_BR



              Hopeful

              Thanked: 5
              • Computer: Specs
              • Experience: Experienced
              • OS: Windows 7
              Re: Combining files
              « Reply #5 on: June 13, 2009, 08:50:36 AM »
              COPY assumes text files, and will terminate at Control Z and anything else which is not a normally printable character.

              COPY /B is a BINARY copy, which duplicates every character regardless of whether it is printable.

              COPY /B file.0* newfile
              That will work,  and is a great way to use up empty disc space.
              It may however disappoint you, newfile will contain copies of files in the sequence that they are given by Windows.
              If you want the contents of file.001 to be followed by file.002 etc etc you need to control the sequence.

              Regards
              Alan

              gh0std0g74



                Apprentice

                Thanked: 37
                Re: Combining files
                « Reply #6 on: June 14, 2009, 01:17:12 AM »
                @OP, if you can afford to install GNU tools (see my sig), common way to do it in *nix can now be done also on Windows
                Code: [Select]
                c:\test> cat file.0* >> newfile.txt