Any way to convert multiple PowerPoint files in a folder to PDF using Windows command line?
It's not fail safe (you can add file existence checks and so on). Save this as a .bat
:
@if (@X)==(@Y) @end /* JScript comment
@echo off
cscript //E:JScript //nologo "%~f0" %*
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
var source=WScript.Arguments.Item(0);
var target=WScript.Arguments.Item(1);
PP = new ActiveXObject("PowerPoint.Application");
PRSNT = PP.presentations.Open(source,0,0,0)
//PRSNT.SaveCopyAs(target,32);
//https://msdn.microsoft.com/en-us/vba/powerpoint-vba/articles/ppsaveasfiletype-enumeration-powerpoint
PRSNT.SaveAs(target,32);
PRSNT.Close();
PP.Quit();
The first argument is the powerpoint file the second is the new file where you want to save it. More info about the presentation object
Next step is to process files(if the previous script is saves as ppt2pdf.bat
):
@echo off
::change the locataion in the line bellow
set "ppt_dir=c:\ppts"
for %%a in ("%ppt_dir%\*pptx" "%ppt_dir%\*ppt") do (
call ppt2pdf.bat "%%~fa" "%%~dpna.pdf"
)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments