About the Author
Esquire | Mac is a blog by Adam Greivell, a 20+ year Mac veteran and Maryland litigation attorney. Adam practices law primarily in Hagerstown, Maryland. Macs are his weapons of choice.
Email Adam
Follow Adam on Twitter
Click here for more about Adam...
Subscribe to this Blog
Search
The Twitters
Disclaimers

(1) It should go without saying, but, I'm a lawyer and I can't keep from saying it: This site is for informational purposes, and is not to be construed as legal advice. I can't imagine how anyone could possibly think anything here equates to legal advice, but in case you did: it doesn't. 
(2) Although I work for the above referenced law firm, this site is not affiliated in any way with that firm. This site is solely a personal endeavor. 
(3) This site has nothing to do with the magazine "Esquire" or esquire.com. Esquire is used in the title here in a purely descriptive sense invoking the traditional definition of the word as a label for an attorney.

Monday
Sep282009

Convert Pages Docs to Word Docs En Masse

After I started at my new firm last month, I decided to rethink my workflow. I began working with Pages (the '08 version), and have found it to be much faster than Word for Mac: 2008. The main problem for me is that I need to save everything as a .doc file so that the others in my office can use them. As I noted earlier, I am the only Mac in this firm, and there is no way for a PC to use the .pages file format (except for doing something crazy like getting iWork '09 and sending everything to iWork.com - like I said: crazy).

The next great hurdle is the fact that Pages will not simply allow you to "Save As" a Word document. You have to "Export." This means that you cannot just set the default save format as .doc. So, I would end up having two documents at the end of the day - one .pages and one .doc. Then, of course, every time I edit the file, I can't just save it again, I have to export it and create yet another file. This is truly a cumbersome process.

I decided to come up with a better solution. The solution I had in mind was one where I could create a way to convert them all at one time. This would enable me to create my documents for work (correspondence, pleadings, notes, etc.) and store them in a holding folder, and then before I file them in their respective places on the server, I could convert them all at once.

What I ended up doing was creating a Folder Action using AppleScript. It actually works just as well with a single document as with many documents.

How It Works

Take your Pages documents, drag them into the folder you have set up, and the script will run and convert each document to a Word document with the same name as it had before, and save it to your Desktop.

To create this script, I borrowed some of the code from MacSparky's post on creating a Folder Action to automatically OCR pdfs placed in a folder with PDFPen. The rest of the code, I borrowed from a page on the MacScripter forums, which is an AppleScript to convert Pages docs to Word docs.

I combined the two because I wanted the documents to convert automatically upon dragging them into a certain folder. It took some tweaking to get the code just right, but it works like a charm - for me, anyway. Your mileage may vary.

In any event, here's the code I ended up with:

on adding folder items to this_folder after receiving added_items
repeat with i from 1 to number of items in added_items
set this_item to item i of added_items
tell application "Pages"
open this_item
set docName to name of front document
-- Remove .pages extension.
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to ".pages"
-- Add .doc extension.
set docName to first text item of docName & ".doc"
set AppleScript's text item delimiters to prevTIDs
-- Save file to Desktop.
set docPathAndName to (path to desktop as string) & docName
save front document as "SLDocumentTypeMSWord" in docPathAndName
close front document
end tell
end repeat
end adding folder items to

You can recreate the script yourself by pasting this text into your AppleScript Editor and saving it, or, you can just download it from here.

After you have your script, place it in Macintosh HD/Library/Scripts/Folder Action Scripts. When you have done that, right click on the folder you would like to be your "drop" folder, and select "Folder Actions Setup..." as seen below.

Select the script you just created (or downloaded), and click "Attach" as shown below.

That's it! Now, to test, just drag one or more Pages documents into the folder and see if Pages goes through its thing and deposits the new Word documents on your desktop.

One final thing I did to make my life easier was to drag the "drop" folder itself into the Dock. Now, any time I want to convert one or more Pages documents, I just drag them into the folder on the Dock, they get deposited there, and their new Word offspring show up on the desktop.

You can fiddle with the script to do anything you like, such as make the new Word docs save to a location other than the desktop.

If you're interested in learning more about AppleScript, I recommend you check out these two posts from MacAppStorm:


« Convert WordPerfect Docs to Word Docs in Bulk | Main | New Job: Only Mac In The Shop »

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    [...]Esquire | Mac - Macs. Lawyers. Simple. - Convert Pages Docs to Word Docs En Masse[...]

Reader Comments (8)

Adam-

Hey, I'm really impressed that you did this. Excellent job.

Paul

September 29, 2009 | Unregistered CommenterPaul F.

Great idea Adam. You also should plunk down your $80 for iWork 09 which allows you to "save as" word in the save dialogue.

Cheers,
MacSparky

September 29, 2009 | Unregistered CommenterDavid Sparks

how does pages handles pleadings & any conversion back and forth between pages & .doc?

October 1, 2009 | Unregistered Commenterdan

Congrats on the new job. I worked in a Windoze environment for a short while (the lone Mac in the firm). Maybe, over time, you can convince them to switch. I know after a few colleagues did the Vista upgrade, they were happy to switch to an Apple.

Thanks for making the script available. I am going to try a variation on it. I will let you know how it goes.

Cheers. AAP

October 9, 2009 | Unregistered CommenterAaron A. Pelley

Hi, I tried all of your directions and my docs in end up in my drop folder and then to my desktop, but when I save them they still have the pages connotation at the end. Any idea what I may have done incorrect?

Thanks

January 29, 2010 | Unregistered CommenterHutch

[...] to Convert Pages Docs to Word Docs En Masse Very nice custom script below that you can attach as a folder action.  Really good work and such a time [...]

Great post, thanks!

Have you considered going to Office for Macs? Is Pages that much better?

April 22, 2010 | Unregistered CommenterNeal

Hey Neal,

I used Office for Mac (2004, then 2008) for years and years. Now that I've opened up my own law firm, I switched to using Pages full time. In my opinion, it runs much more smoothly - fewer crashes; loads more quickly, etc.

April 22, 2010 | Unregistered CommenterEsquireMac

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>