How can I combine multiple text files into one file

I have searched extensively and while I see information on how to combine many other file types, I simply want to combine about 50 text files, which I have put into their own folder, into one text file in the alphabetical order they are in. Is this so simple no has posted how? I don't know how and would appreciate the help.

MacBook Pro, Mac OS X (10.7.4)

Posted on Nov 8, 2018 9:55 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 8, 2018 10:23 AM

By text files, do you mean plain text?


If so, this is trivial to do with the Terminal.


1) Open Terminal

2) Type "cd " (without quotes but with the trailing SPACE)

3) Drag and drop the folder icon of the folder that has your files, from the Finder onto the Terminal window

4) Press return

5) Type "cat * > ~/Desktop/allthefiles" (again, without the quotes, but exactly as typed; you can of course change the last name to something other than "allthefiles", but respect all the rest, including spaces)


You are left with a file on your desktop, called "allthefiles", with the concatenation of text from all the files in the aforementioned folder.



If they are "rich text" files, then this will not work, and something more elaborate is needed.

2 replies
Question marked as Top-ranking reply

Nov 8, 2018 10:23 AM in response to Raynakapec

By text files, do you mean plain text?


If so, this is trivial to do with the Terminal.


1) Open Terminal

2) Type "cd " (without quotes but with the trailing SPACE)

3) Drag and drop the folder icon of the folder that has your files, from the Finder onto the Terminal window

4) Press return

5) Type "cat * > ~/Desktop/allthefiles" (again, without the quotes, but exactly as typed; you can of course change the last name to something other than "allthefiles", but respect all the rest, including spaces)


You are left with a file on your desktop, called "allthefiles", with the concatenation of text from all the files in the aforementioned folder.



If they are "rich text" files, then this will not work, and something more elaborate is needed.

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 can I combine multiple 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.