Last active
November 8, 2021 18:24
-
-
Save carlpch/bec4189fc46f24d3c612c381805d6bfc to your computer and use it in GitHub Desktop.
Applescript for batch saving PowerPoint files into PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an update of codes from a Reddit post. The post is locked or otherwise I will just post this there! | |
# https://www.reddit.com/r/osx/comments/4gg3t3/batch_converting_powerpoint_2016_to_pdf_in/ | |
# It is recommended that you also sep up a filter (on Automator) to make sure the file format is compatible. | |
on run {input, parameters} | |
tell application "Finder" | |
set theItems to input | |
repeat with itemRef in theItems | |
set theItemParentPath to (container of itemRef) as text | |
set theItemName to (name of itemRef) as string | |
set theItemExtension to (name extension of itemRef) | |
set theItemExtensionLength to (count theItemExtension) + 1 | |
set theOutputPath to theItemParentPath & (text 1 thru (-1 - theItemExtensionLength) of theItemName) | |
tell application "Microsoft PowerPoint" | |
launch # required, or PowerPoint will return with parameter error | |
open itemRef | |
tell active presentation | |
save in theOutputPath as save as PDF | |
close | |
end tell | |
end tell | |
end repeat | |
end tell | |
end run | |
# Running this script sometimes requires additional authorization of file access to PowerPoint. | |
# Any idea how to remove that prompt to grant file access will be appreciated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment