Concatenating .rtf files

I have a couple hundred .rtf files that I need to concatenate with page breaks between them. I then want to print the output to a .pdf file.

I've tried various combinations of Textedit and Finder actions in an Automator workflow but so far with no success.

Thanks, Hal

iMac 17 1Ghz, Mac OS X (10.4.3)

Posted on Jan 9, 2006 3:50 PM

Reply
3 replies

Jan 10, 2006 5:33 AM in response to Hal Work

Hi Hal, welcome to Apple Discussions. While Automator has a Combine PDF Pages action it lacks a Convert RTF to PDF action. Not to worry, we can write one ourselves fairly painlessly using Automator's Run AppleScript action. Here's the code you'll need:

click here to open this script in your editor <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">on run {input, parameters}
set pdf_items to {}
repeat with x in input
POSIX path of x
set {rtf_input, pdf_output} to {quoted form of result, result & ".pdf"}
do shell script "/System/Library/Printers/Libraries/convert -f " & rtf_input & " -o " & quoted form of pdf_output & " -j \"application/pdf\""
set end of pdf_items to pdf_output as POSIX file as alias
end repeat
return pdf_items
end run</pre>
...and here is what your workflow might look like:
User uploaded file

PowerMac G5 (June 2004) 2x1.8GHz 1.25GB, PowerBook G4 (12-inch DVI) 1x1GHz 768MB Mac OS X (10.4.3)

Jan 10, 2006 5:50 AM in response to Michael Henley

...once you've got that set up, just run the workflow and select a bunch of RTF files. It will create a new PDF for each RTF file and then combine those into the final document. Note that while the script doesn't overwrite anything, it does generate a lot of extra PDF copies that you may wish to delete manually. Since the RTF to PDF bit creates whole, paginated documents, you won't need to worry about inserting page breaks yourself. The combined PDF file winds up in a hidden temporary directory that is flushed regularly, so you'll want to make sure and save it somewhere using either Preview or perhaps another action.

Let us know if you have any trouble.

PowerMac G5 (June 2004) 2x1.8GHz 1.25GB, PowerBook G4 (12-inch DVI) 1x1GHz 768MB Mac OS X (10.4.3)

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.

Concatenating .rtf files

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