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


Click here to return to the 'Batch convert Word files to PDFs via Pages' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Batch convert Word files to PDFs via Pages
Authored by: soopah256 on Jun 16, '10 04:32:35PM

Thanks for the code! It's exactly what I needed.
My files names included a "." in the filename, so I tweaked the code so that it preserves the full filename. (the *.doc extension must be present)

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 ".doc" 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 ".doc" 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



[ Reply to This | # ]