Hello, newbie to AppleScript and stuff like that. I have been using automator to do some great stuff (also with an apple script which I copied from the internet to OCR document in a folder with PDFpen).
I would really like to be able to have a folder action in automator that will look for document to be dropped in that folder, and if the extension is docx or doc , it will then open the file with PDFpen and save it (as a pdf) in the same folder (or if this is not possible a different folder). So all PDFpen has to do is open and save (same name as file opened).
I have searched and searched, but I Cann’t find how to solve this. Is there anybody who wants to help me? Reason I want to do this automatically is that I quite often work on a file in Word and then save the file as a docx to be able to work on it in the future, but I want to send that same copy to somebody by mail. (I do have an automator executing an email from a certain folder).
I hope this can be done.
I searched as well, and everything seems to be about the more “whizz-bang” feature of PDF—>Word.
My suggestion is to contact Support for PDFpen. I bet someone there has already invented this wheel.
Yes, that is what I found as well. Good idea to contact them. Didn’t even think about that
If I understand your task, you want to be able to drop a Word document into a folder and have a PDF version automatically created, correct?
If so, I would approach it this way. MS Word is scriptable via AppleScript although as usual the syntax is convoluted. Because I do not have MS Word, I cannot test out my syntax, but here’s my suggestion:
If you have Hazel you can do this via Hazel rules, which would allow you to set the needed criteria, eg the file has an extension of .doc or .docx, and potentially other criteria for selection (for example, only run on a file that has been present for more than some specified time, or check for a Finder tag (so that you can can be working on files in the folder, but only when you apply a “convert to PDF” tag does the rule run, etc. Or of course you can work with your Word documents in other folders and copy them to the target folder when you want the PDF automatically created.
The Hazel rule, when matched, actions an AppleScript which needs to:
tell application “Word”
Set the inputFilename to the file name supplied by Hazel
Open the file name and get the active documented
You then use the “Save as” application verb with the “active window” which should be the document just opened, “in file “ where the file name is the Hazel file name with the extension changed to .pdf, and something that will look like “using file format format PDF” to have the save done as a pdf. Note that the word format is repeated as I have typed it, but some experimentation or google searching will be needed to get the exact syntax depending on your Word version.
Once the save is done, close the window. If you used the trick of a Finder tag to trigger the Hazel rule, you might want to remove the tag at that point. You might want the PDF moved somewhere, or if you are dropping the files into the folder to trigger the pdf generation you might want to move the word document to the Trash (make sure you are copying tiles to this folder and not moving them there if you do this! Or, have a separate Hazel rule that removes word documents from the folder after some period of time to clean up the folder.
Hope this helps.
Thanks for your answer. I will try what you suggested and will come back to you