How to combine numerous text files into one file.

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.

MacBook Pro 13", macOS 10.14

Posted on Feb 22, 2019 12:22 PM

Reply
Question marked as Top-ranking reply

Posted on Feb 22, 2019 1:35 PM

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.


6 replies
Question marked as Top-ranking reply

Feb 22, 2019 1:35 PM in response to pastorchris

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.


Feb 22, 2019 3:11 PM in response to VikingOSX

"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. 😉

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to combine numerous text files into one file.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.