How to combine / merge many files into one file

How to combine / merge many files into one file

3
NewbieNewbie
3

    Mar 29, 2005#1

    Hi,

    Does UE have a way to combine many files into one? I know I can open each file in a separate tab, create a new blank file and then copy/paste each one at the end of the new one but that's a pain.

    Any help would be appreciated.

    Thanks!

      Mar 30, 2005#2

      Duh, I can't believe that I even posted this. Classic example of overthinking.

      All I had to do was go to the command prompt and do the COPY command. It worked great in this situation because all the files were in one directory and they all had the same extension.

      Thanks anyway!

      1
      NewbieNewbie
      1

        Feb 18, 2006#3

        Hi pantichd,

        I also would like to get many files compiled into one but I couldn't do it as I am not familiar at all with the editors program.. :(
        So would you mind please tell me step by step how can I merge all content of al files into one withou copy/past XXX times.

        Thanks in advance for you help.

        Chris.

        6,675585
        Grand MasterGrand Master
        6,675585

          Feb 18, 2006#4

          Pantichd has not done it with UltraEdit. He has used old DOS command COPY from a Windows DOS shell.

          Click on Windows Start button, select Run from the menu and enter cmd (for Windows NT/2000/XP) or command (for Win98/ME) and press OK. A DOS shell will open.

          Goto the directory where you have the files to which contents should be merged to a single file. For example if they are at E:\Data Files enter following in the DOS shell (press ENTER for each line):

          E:
          cd "E:\Data Files"


          Now enter following to get help about the good old copy command:

          copy /?

          This should give you enough information on how to use the copy command to merge the contents of a few files to one file. Two examples - an easy and a hard one:

          copy *.txt Allfiles.txt

          Copies all files with the extension *.txt in the current directory to the file Allfiles.txt in the current directory.

          copy "File 1.txt"+Testx\File2.txt+"Other File.ini"+C:\Windows\Temp\Test.dat" "F:\Temp Files\MergeFiles.txt"

          Copies File 1.txt in the current directory (contains a space in the filename so surrounding double quotes are needed) and File2.txt in the subdirectory Testx of the current directory and file Other File.ini in the current directory and the file Test.dat in the directory C:\Windows\Temp to the file MergeFiles.txt in the directory F:\Temp Files.

          To close the DOS shell window when you are finished enter exit.

          Of course you can run the DOS command also from within UltraEdit using Advanced - DOS Command.


          Is this too complicated for you? Then use this macro to merge the content of all open files to a new file:

          Clipboard 9
          ClearClipboard
          Loop
          IfNameIs ""
          ExitLoop
          EndIf
          Bottom
          IfColNum 1
          Else
          "
          "
          EndIf
          SelectAll
          CopyAppend
          CloseFile NoSave
          EndLoop
          NewFile
          Paste
          Top
          ClearClipboard
          Clipboard 0

          How this macro works:

          If the name of the current file does not exist (no file open anymore or the current edit window is just a file buffer which content is not saved to file), exit the content collecting loop.

          If the current file has a name, goto the end of the file and check if the last line is terminated with a line ending. If the last line of the file has no line ending, insert one to make sure that last line of a file is not merged with the first line of the next file in one line. Then select everything of the file and append it to current content of user clipboard 9. Then close the current file without saving it.

          After the loop has finished (normally no document is open anymore), create a new file and paste the clipboard content. Goto top of the new file, clear content of user clipboard 9 and switch back to windows clipboard.

          The window history order (Window - Next Window) defines the order how the contents are merged and not the file tab order (Window - Next File Tab)!