0

I'm trying to concatenate several .doc files none of them bigger than 15 KB, I'm trying the usual

cat file1.doc file2.doc file3.doc > new_file.doc

But despite the result is an almost 200 KB new .doc file this only shows the first of the original .doc files content.

Any ideas? What I'm doing wrong? It's not possible to concatenate .doc files with cat?

Any help is appreciated.

Thanks in advance.

4
  • 3
    This is why sysadmins and devs tend to dislike binary formats.
    – Wildcard
    Commented Aug 19, 2016 at 22:57
  • Yeah! try to explain that to regular user.... Thanks anyway! Commented Aug 19, 2016 at 23:09
  • Wow!! @don_crissti that's a good one that I didn't know!! I'm going to try that cause the user it's using libreoffice and converting into .doc(stupid I know) from now on she'll must be compelled to save her files in .odt or manually merge them herself!! :DDD Thanks a lot, this is the best answer! Commented Aug 19, 2016 at 23:30

3 Answers 3

4

You can convert files like *.doc to *.html with the writer from LibreOffice:

lowriter --convert-to html $doc_filename

Then you can cat them in any order including formatting and images (if they are in the same directory or if their full path is specified).

Finally, you can use the same command to convert them back to the Word format:

lowriter --convert-to doc $html_filename
3

This is because .doc files are in Microsoft Word format, not plain text files that you can concatenate together.

The file's header will actually tell your word processor how the data is organized, therefore only listing the first part.

In order to combine them together, you would need to import them using a word processing application and then append them to each other.

1
  • Bloody Microsoft!!! Always making a hell of my life. Thanks Julie. Commented Aug 19, 2016 at 23:04
2

That won't work, as .doc(and many other types of files) have internal structure: Some sort of header containing overview information, and then the contents themselves. If you squash two of those together, in the best case the application will only "see" the first one, or will see that the length doesn't match, or that there is some unexpected stuff after the expected end, and consider the file damaged.

Text files are just a string of lines. Adding another string of lines at the end gives a well-formed, longer, text file. Adding lines to a .doc file is a much more involved operation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .