Merging Pages docs using Terminal

Hi,


I have written a number of chapters for my new book in Pages and now I want to send them all to my friend in order to get some feedback.

But first, I would like to combine them to one document.

I have searched the internet, most useful method seems to be the 'cat' command in Terminal:


cat file1.txt file2.txt file3.txt >> file4.txt


Okay, these are text files, but why would not this work for Pages documents? (That's what I am thinking.)


So I open a Terminal window, I type 'cat' and then I drag and drop the list of the Pages docs from Finder to Terminal, e.g.

cat file1.pages file2.pages file3.pages >> newfile.pages

But afterward I am very disappointed to see that 'newfile.pages' only contains the contents of file1.pages.

Doesn't the cat command work for Pages? Is there another solution for me then?

Thanks a lot for your help.

Mac mini, macOS 11.5

Posted on Aug 1, 2021 2:16 PM

Reply
3 replies

Aug 2, 2021 5:15 AM in response to Mr Moto

Pages documents are compressed zip containers with internal binary data that have been renamed with the .pages extension. There is no means to concatenate these as you have shown for plain text files.


I suggest that you export each Pages document to PDF, and then using Apple's Preview, combine the PDF files in that application. Send the final result to your friend in PDF format.


See Combine PDFs in Preview on Mac.

Aug 2, 2021 1:39 AM in response to Mr Moto

The cat command does exactly this: it appends the bytes from one file to the end of the bytes of the other file. It has no notion of any internal document structure. So this only works for plain text files, it cannot work for pages files as there is a pretty complex internal logical structure to the bytes in the file which will be corrupted by simply appending bytes.


Your best bet is to use Apple Script for this task. Sorry, I can only tell you why your approach does not work, but I cannot help you with Apple Script. I do hope others chime in here.

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.

Merging Pages docs using Terminal

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