Skip to main content

Posts

Showing posts from March, 2017

script to recursively convert word docs to pdfs

prerequisites:  you have to have ms office with the version which lets you save docs as pdf    two steps   first create this script file to use ms office plugin  and name it as conv.js var fso = new ActiveXObject("Scripting.FileSystemObject"); var docPath = WScript.Arguments(0); docPath = fso.GetAbsolutePathName(docPath); var pdfPath = docPath.replace(/\.doc[^.]*$/, ".pdf"); var objWord = null; try {     WScript.Echo("Saving '" + docPath + "' as '" + pdfPath + "'...");     objWord = new ActiveXObject("Word.Application");     objWord.Visible = false;     var objDoc = objWord.Documents.Open(docPath);     var wdFormatPdf = 17;     objDoc.SaveAs(pdfPath, wdFormatPdf);     objDoc.Close();     WScript.Echo("Done."); } finally {     if (objWord != null)     {         objWord.Quit();     } } then run this powershell command Get-ChildItem -rec | Where-object {!$_.psIsC