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


Click here to return to the 'Bulk convert text files to PDF' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Bulk convert text files to PDF
Authored by: musselrock on Jun 06, '11 12:07:42PM

For Word documents, either of these scripts, saved as applications, will batch Word files to PDF, The first uses Pages which I like to use the best as it preserves the hyperlinks in Word docs. The second script does it with Word (2008), but hyperlinks are lost.

First script:
(* Drag and drop batch conversion of Word docs or any document that can be opened by the Pages application to PDF files. *)

on open filist
tell application "Finder"
set defLoc to container of (item 1 of filist) as alias
end tell
set destn to choose folder with prompt "You are about to copy files to PDFs using Pages." & return & "Select a location to save the converted files." default location defLoc
repeat with lvar in filist
tell application "Finder"
set thename to name of lvar
set filex to name extension of lvar
set l to length of filex
end tell
set nuname to text 1 thru text item -(l + 1) of thename
tell application "Pages"
launch
set filname to (destn as string) & nuname & "pdf"
open lvar
save document 1 in filname
close every window saving no
end tell
end repeat
end open

Second script:
(*Batch convert Word files to PDF using Word 2008*)
on open fillist
set bs to "/"
set d to "-"
tell application "Finder"
set defLoc to container of (item 1 of fillist) as alias
end tell
set destn to choose folder with prompt "You are converting Word files by copying them to PDF files." & return & "Select a location to save converted files." default location defLoc
repeat with lvar in fillist
tell application "Finder"
set thename to name of lvar
set filex to name extension of lvar
set l to length of filex
end tell
set nuname to text 1 thru text item -(l + 1) of thename
if "/" is in nuname then
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to bs
set txtLst to every text item of nuname as list
set AppleScript's text item delimiters to d
set nuname to txtLst as string
set AppleScript's text item delimiters to oldDelims
end if
set filname to (destn as string) & nuname & "pdf"
tell application "Microsoft Word"
launch
open lvar
save as active document file name filname file format format PDF
close window 1 saving no
end tell
end repeat
end open



[ Reply to This | # ]