First off, big THANK YOU to all of the help this forum has provided. I’ve only been working with Applescript for about a month and a half now and without forums like these I don’t think I’d be half as far as I am in my learning. Now, the bad news.
I’m working on a rather complicated script that invloves several apps. Quick rundown:
1.Drop files on script
2.If file is IDCS2 check for facing pages, count pages, get dimensions, export as pdf
3.If PDF shell script for dimensions and shell script for page count
4.If not PDF or IDCS2 error
5.Photoshop opens PDF sets dimensions and dpi saves each page as PNG
6.PowerPoint inserts each PNG into new slide
Per request here is the script:
on run
display dialog "This is a droplet, drag and drop InDesign or PDFs to be converted ino PowerPoint." buttons {"OK"} with icon 0
end run
on open theFiles
do shell script "rm -rf /Library/Caches/Scripting/PowerPoint\\ Maker/*"
tell application "Finder"
if not (exists folder "Macintosh HD:Library:Caches:Scripting") then
make new folder at "Macintosh HD:Library:Caches" with properties {name:"Scripting"}
end if
if not (exists folder "Macintosh HD:Library:Caches:Scripting:PowerPoint Maker") then
make new folder at "Macintosh HD:Library:Caches:Scripting" with properties {name:"PowerPoint Maker"}
end if
set TempPath to "Macintosh HD:Library:Caches:Scripting:PowerPoint Maker:"
display dialog "Would you like to keep the PNG files after the PowerPoint file is made?" buttons {"Yes", "No"} with icon 1
set savePNGs to button returned of result
repeat with i from 1 to count theFiles
set fileType to file type of (info for theFiles)
if (fileType is "IDd4") then
tell application "Adobe InDesign CS2"
activate
open theFiles
set myInddDoc to active document
repeat with t from 1 to count myInddDoc
set user interaction level of script preferences to never interact
set p to 1
tell myInddDoc
count every spread
if (count every spread of myInddDoc) is greater than 1 then
set hasSpreads to true
else
set hasSpreads to false
end if
if hasSpreads is true then
display dialog "One PAGE per slide or one SPREAD per slide?" buttons {"Page", "Spread"} with icon 1
set slideType to button returned of result
display dialog "What background color for the slides?" buttons {"Blue", "White"} with icon 1
if button returned of result is "Blue" then
set backgroundColor to {169, 183, 195}
else
set backgroundColor to {250, 250, 250}
end if
if slideType is "Page" then
set pageCount to count every page
set PDFpreset to PDF export preset "PPMaker-Single Pages" of application "Adobe InDesign CS2"
end if
if slideType is "Spread" then
set pageCount to count every spread
set PDFpreset to PDF export preset "PPMaker-Spreads" of application "Adobe InDesign CS2"
end if
else
if hasSpreads is false then
set PDFpreset to PDF export preset "Slide PDF Export" of application "Adobe InDesign CS2"
end if
end if
set DocPath to file path as string
set pageWidth to (page width of document preferences)
set pageHeight to (page height of document preferences)
set AppleScript's text item delimiters to {"."}
set RealDocName to first text item of DocPath
set AppleScript's text item delimiters to {""}
set DocName to ((characters 1 thru 16 of RealDocName) as string)
set PDFfile to TempPath & DocName & ".pdf"
set page range to all pages
export format PDF type to PDFfile using PDFpreset without showing options
close saving no
end tell
end repeat
end tell
set weirdness to false
else
if (fileType is "PDF ") then
set pageCount to (do shell script "/usr/bin/mdls -name kMDItemNumberOfPages " & quoted form of POSIX path of theFiles & " | /usr/bin/grep -o '[0-9]\\+$'") as integer
set {pageWidth, pageHeight} to paragraphs of (do shell script "mdls " & quoted form of POSIX path of theFiles & "| grep 'kMDItemPageHeight\\|kMDItemPageWidth' | awk '/ = / {print $3}'")
set DocPath to file path as string
set weirdness to false
else
set weirdness to true
error "PDF or InDesign documents only, please."
end if
if weirdness is false then
set PNGDocPath to make new folder at TempPath with properties {name:(DocName & "_PNGs")}
set PNGDocPath to (PNGDocPath as string)
tell application "Adobe Photoshop 7.0"
activate
set oldUnits to ruler units of settings
set ruler units of settings to pixel units
set oldColor to background color
repeat with x from 1 to pageCount
if pageHeight is greater than pageWidth then
set theSide to {height:960}
else
set theSide to {width:1280}
end if
set PDF_Options to {class:PDF open options, constrain proportions:true, resolution:128, mode:RGB, use antialias:true, page:x} & theSide
open file PDFfile with options PDF_Options showing dialogs never
set thisFile to current document
tell application "Finder"
set PNGDocName to name of thisFile
set AppleScript's text item delimiters to {"."}
set PNGDocName to (first text item of PNGDocName)
set AppleScript's text item delimiters to {DocName}
set fileNum to second text item of PNGDocName
set AppleScript's text item delimiters to {""}
set PNGDocName to "image" & fileNum
end tell
set PNG_File to save thisFile in file (PNGDocPath & PNGDocName) as PNG appending lowercase extension
close PNG_File saving no
set ruler units of settings to oldUnits
set background color to oldColor
end repeat
end tell
tell application "Finder"
set FolderList to (every item of folder PNGDocPath whose name contains ".png")
mount volume "afp://10.10.50.20/Volume2"
open "Volume2:ABC Templates and Resources:Slide Templates:PPT Slide Template - Black.pot"
tell application "Microsoft PowerPoint"
activate
set pptFile to DocPath & RealDocName & ".ppt"
tell active presentation
repeat with m from 1 to (count FolderList)
set newSlide to make new slide at the end
set picture_shape to make new picture at newSlide with properties ¬
{lock aspect ratio:false, file name:((item m of FolderList) as string)}
scale height picture_shape factor 1.0 scale scale from top left with relative to original size
scale width picture_shape factor 1.0 scale scale from top left with relative to original size
solid picture_shape
set fore color of fill format of picture_shape to (backgroundColor as RGB color)
set left position of picture_shape to (360 - ((width of picture_shape) / 2))
set top of picture_shape to (270 - ((height of picture_shape) / 2))
end repeat
delete first slide
end tell
save active presentation in pptFile as save as presentation
arrange windows arrange cascade
end tell
if keepPNGs is "Yes" then
move folder PNGDocPath to DocPath
end if
set PNGDocPath to POSIX path of file PNGDocPath
set PNGDocPath to quoted form of PNGDocPath
do shell script "rm -rf " & PNGDocPath
end tell
else
error "File(s) not found. Try clicking the finder window that contains your file(s) and give it a second to refresh."
end if
end if
end repeat
end tell
end open
Thanks for any input!!
Stacy