Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to combine Word documents Apps
Have you ever had the need to combine two or more Word documents? Sure, you could open each in Word, select all the text in one, copy it, and paste it into the other. But that's a lot of work.

Instead, just try this AppleScript. Copy and paste into Script Editor, and save it as an application (File: Save As, Format = application) in a convenient location. When you launch it, a dialog will prompt you to select two (or more) Word documents. Hold down the Command key, and click on each document you'd like to combine.

When you click Choose, Word will open and then create a new document holding the combined content of each of your chosen files.

[robg adds: geppo1982 wrote the AppleScript, but English is not his native tongue, so he asked me to create the writeup. The script worked as described in my testing.]
    •    
  • Currently 3.67 / 5
  You rated: 4 / 5 (6 votes cast)
 
[25,825 views]  

An AppleScript to combine Word documents | 18 comments | Create New Account
Click here to return to the 'An AppleScript to combine Word documents' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to combine Word documents
Authored by: wrycooter on Mar 23, '06 09:28:20AM

BBEdit is my word processor of choice (as opposed to a word FORMATTER like Word) It is really a TEXT processor, and I could probably easily say over 99% of my text documents are as Text rather than Word documents.

I think there may actually be an easy way to cocatenate (clobber together) various text files (BBEdit, TextEdit, TeachText etc) within BBEdit itself, but back before OS X, I used this classic application called, simply enough, Cocatenate. Is there anything out there like Cocatenate for OS X?



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: semiotek on Mar 23, '06 10:05:57AM

Doesn't work for me - apparently the aliases for the two documents don't understand the <<event daVSnoOI>> message!



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: Baggins on Mar 23, '06 11:16:01AM

Adobe InDesign is a word formatter.

Word is a word processor with some formatting capabilities. BBEdit is a text editor with some word processing capabilities.

Some people are anally retentive pendantics.



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: weeksatinsead on Mar 23, '06 12:13:19PM

For pure text files, you can use "cat" in the terminal.

cat file1.txt file2.txt > file1and2.txt



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: MJCube on Mar 23, '06 02:40:20PM
One more note of pedantry to wrycooter: The word you want for concatenating is not clobber, which means to hit hard (or in the Unix environment, to overwrite a file), but cobble.

Back on the topic, I also keep many files in plain text, especially now with TextWrangler's full Unicode support. For actual text formatting (without too much advanced layout), for me STILL nothing beats Word 5.1 (from 1992!) I actually still use it in Classic just to continue to keep all my invoices in the same old file. But in the last few years I have become much more friendly with TextEdit (and RTF code itself) for new documents.

[ Reply to This | # ]

An AppleScript to combine Word documents
Authored by: jacobolus on Mar 23, '06 06:10:33PM

Word 5.5 was excellent.

God why did they ever release version 6? It's been downhill ever since. Now, 15 years later, Word 5.5 beats the socks off Word 2004.



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: jacobolus on Mar 23, '06 06:12:53PM

Ack. 5.1 rather.



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: Token on Mar 24, '06 05:50:21AM

I think the rationale behind Word 6 for Mac was an attempt on side of MS to bring the code bases of the Windows and Mac version on par. This wholeheartedly 'altruistic' move would probably also save them some work later on, so they thought. What they created was a horrible monster, extremely unstable..

As we who suffered much laughing from pc using friends can attest to, that wasn't a very smart move :-)



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: jacobolus on Mar 23, '06 06:15:41PM
One more fun link, from TidBITS, april fools 2003, "Microsoft Word 5.1 for Mac OS X": http://db.tidbits.com/getbits.acgi?tbart=07139

[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: rammjet on Mar 23, '06 10:05:34AM

Both Word and BBedit have menu items to insert a file at the position of the cursor.

In Word: Insert > File...
In BBedit: Edit > Insert > File...



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: ever on Mar 24, '06 10:31:30PM
I believe man textutil also concatenates doc files.

[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: willisjw on Jun 01, '06 06:37:26PM

Doesn't work for me. I get "Expected end of line, etc. but found class name." at the insert file instruction



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: robg on Jun 01, '06 07:07:09PM

Worked just fine here in testing now -- 10.4.6, latest Office 2004 updates installed.

What version of OS X, etc. do you have?

-rob.



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: thejeff on Jul 19, '06 04:50:55PM

I also have this same problem. 10.4.7, Microsoft Word X. Does it require 2004?

Thanks



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: RSoldin on Feb 21, '07 03:46:27PM

Doesn't work for me. I get "Expected end of line, etc. but found class name." at the insert file instruction

This is when you try to save the script in the editor. I am not educated with scripting much, so I don't know what to do to fix this. Can someone help with this line?

Thanks



[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: TyGrrrBalm on Dec 21, '09 08:58:26AM
This is great. Anybody know how to make an automated version? Like -- use this script to merge all Word docs in a directory, and then schedule it to run once every three days using cron?
All advice is much appreciated!

[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: pwf on Oct 29, '11 05:16:58PM

To use this script with MS Word 2008 (.docx) files, modify the only_doc(my_list) function by replacing

com.microsoft.word.doc

with

org.openxmlformats.wordprocessingml.document


[ Reply to This | # ]
An AppleScript to combine Word documents
Authored by: leon on Jun 23, '12 08:06:14PM

Thanx, you made my day. I was spending 2 hours looking for a solution, nearly all were PC related, all that stuff didn't work out with me (subdocuments, insert text from file - which didn't exist, etc), I had to merge 70 to 90 docs in word 2008 (don't like 2010). Your script worked perfectly, thank you a lot, I am glad I found it.
:)



[ Reply to This | # ]