Benches macOS

7

How to combine numerous text files into o…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Is there a program to combine numerous text files (150+) into one file? Is there an application for this? I know there is a way to do it by typing the title of each file with a command line, but I have too many files to this.

Thanks for any help.

7 replies

Sign in or join Beachball Help to reply.

  1. 0

    VikingOSX

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    See my command-line response to your other question regarding this task. No filename typing needed.

  2. 0

    MrHoffman

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    What sort of text file format is in use here?

    ASCII or RTF files are going to be somewhat easier to process and append than Microsoft Word documents might be, for instance.

    For a text file as is commonly used at the command line, an example concatenation command can be:

    cat *.txt > /path/to/elsewhere/merged.txt

    That'll take anything in the current default directory with a .txt extension, and stuff it all onto one rather-larger text file else-path.

    Automator.app can also be used for these sorts of tasks, and the Combine Text Files action is probably going to be relevant here.

  3. 0

    VikingOSX

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    See my command-line response to your other question regarding this task. No filename typing needed.

  4. 0

    VikingOSX

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Single chevron to overwrite each file, double chevron to concatenate. 🤓

  5. 0

    MrHoffman

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Single chevron to overwrite each file, double chevron to concatenate. 🤓

    Works for me...

    $ echo "x" > x.xyz

    $ echo "y" > y.xyz

    $ echo "z" > z.xyz

    $ cat *.xyz > tmp.txt

    $ cat tmp.txt

    x

    y

    z

    $

  6. 0

    VikingOSX

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I apologize. You are correct. All these decades I fell into a '>' overwrite and '>>' concatenate mindset — starting with UNIX System III, and a plethora of other UNIX operating systems — where I apparently never experimented with wildcards and a single chevron to concatenate. Bit by my own dogma. 🙃

  7. 0

    MrHoffman

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    "cat" is some ancient Unix developer's idea of shorthand for "concatenate", and this example is one invocation of cat rather than a series of invocations of cat. If it were multiple cat commands appending onto the same file, then > (truncate) would be used for the first cat and the second and subsequent cat commands would use >> (append) on the file. But you know this.

    And please keep your dogma 🐕away from my cat 🐈. I'm pretty sure they won't get along. 😉