Could you help me with my Applescript?
December 18, 2012 7:35 AM   Subscribe

I am trying to batch convert a bunch of MS Word documents via Pages on my Mac. I have an Applescript that I believe will work, but I am getting hung up on a dialog box, and I am trying to see if someone could proofread the script for me.

What is happening is this: the Word files were created in MS Word, but the script is using Pages for the conversion. When the script opens Pages, a dialog box opens asking if I want to "review the warnings," and I believe this is what is causing the script and Pages to crash.

So, I am wondering if it is possible to add a line to the script that automatically selects "Don't Review" so the conversion can take place.

Here is the script I am working with. Any help would be appreciated. Also, I am using Mountain Lion and Pages 09. Thanks!

on open filist
if application "Pages" is running then
repeat with lvar in filist
tell application "Finder"
set thename to name of lvar
set thepath to container of lvar
end tell
set x to the offset of "." in thename
set nuname to text 1 thru text item x of thename
tell application "Pages"
activate
set filname to (thepath as text) & nuname & "pdf"
open lvar
save document 1 as "SLDocumentTypePDF" in filname
close every window saving no
end tell
end repeat
else
repeat with lvar in filist
tell application "Finder"
set thename to name of lvar
set thepath to container of lvar
end tell
set x to the offset of "." in thename
set nuname to text 1 thru text item x of thename
tell application "Pages"
activate
set filname to (thepath as text) & nuname & "pdf"
open lvar
save document 1 as "SLDocumentTypePDF" in filname
close every window saving no
end tell
end repeat
tell application "Pages" to quit
end if
end open
posted by 4ster to Computers & Internet (3 answers total)
 
This Automator script handles it in a slightly different way, which might be helpful. I haven't tested it, but it was written fairly recently (August 2012) and the author seems to be fully upgraded to 10.8.
posted by bcwinters at 10:23 AM on December 18, 2012


That one works well, it just only works on one file at a time.
posted by 4ster at 10:50 AM on December 18, 2012


If you start the Automator action with a "Service receives selected [files or folders] in [Finder.app]" as the action recommends, it should work just fine with multiple files. The script itself acts on one file at a time, but it will step through them.
posted by bcwinters at 12:25 PM on December 18, 2012


« Older Traveling to Minneapolis in ea...   |  How do you deal with a doctor ... Newer »
This thread is closed to new comments.