0

I have several hundred PowerPoint (.pptx) files that I want to import into Google Drive and then use natively as Google Slides. I know I can convert them to Google Slides one by one, by opening them and selecting "Save as Google Slides."

Is there a way to convert them on import to Google Drive? Or to convert them in bulk after import?

1 Answer 1

1

You can't do it natively using the web application however I wrote a sample script that can do it for you.

Script

function batchPowerPointToSlides(){
  const limit = 25;  // limits number of files processed before exiting
  const folders = [];
  const folderIds = [ 
    //  Source and Destination can be the same, but Source
    //  and Proceesed PPTX should be different or PPTX files
    //  will be re-processded on next run.   
    "k0d3NQ1SqGL88NGVhFv0HjrHhPDmjx7lv",    //   Source
    "Iau1hXrWMXhyET6evnfW762VecoShP3e3C",   //   Destination
    "WMIyEXrx88evnfW31h6VauXShh22co2e3C",   //   Processed PPTXs
  ];
  
  try {      //  aborts script if any folder is not found    
    folderIds.forEach(id => folders.push(DriveApp.getFolderById(id)));
  } catch(e) {
    return console.log("Script Aborted:\n", e);
  }; 
  const regx = /(.*)\.pptx$/;
  const files = folders[0].getFiles();   // get files from source folder

  while ((files.hasNext() && (counter < limit))  {
    let file = files.next();
    let name = file.getName();
    
    if (regx.test(name)) {
      Drive.Files.create({ 
        name: name.match(regx)[1], 
        mimeType: MimeType.GOOGLE_SLIDES,
        parents: [folderIds[1]],
      }, 
        file.getBlob(), 
      {
        ocrLanguage: 'en'
      }); 
    file.moveTo(folders[2]);   // moves PPTX from Source to Processed PPTX folder 
    }
  }
}

Instructions

  1. You need to supply the script with Google Drive folder IDs for each of the following so those folders should be created first:
    1. Source Folder
      Contains the PPTX files to be processed.
    2. Destination Folder
      For the Slides files that are created.
      NB: Can be the same as the source folder or different.
    3. Processed Folder
      For the PPTX files that have already been converted.
      NB: Can be the same as the destination folder as long as it isn't the same as the source, so files are only processed once.
  2. The script should be copied into a new project in your Google Apps Script console (script.google.com)
  3. In order to avoid exceeding Google's time limit of 6 minutes, the script has a customizable limit constant that will stop the script after the file limit is reached. It is currently set to 25. You can test and increase the limit based on the execution times you are seeing for your batches.
  4. The Drive API v3 needs to be added to Services
    1. Click the 'Add a service' button beside Services
      Services > Add a service
    2. Scroll to 'Drive API' and select it. The default should be v3 (version 3), adjust it if it isn't, then click the Add button.
      Add Drive API v3
    3. The Drive API will now be listed under Services.
      Drive API now listed under Services
  5. Run the script in the editor by clicking the Run button with the function batchPowerPointToSlides selected (should be already since it's the only function in the script). You will need to approve the permissions the first time you run it.
    Run function 'batchPowerPointToSlides' in the editor
  6. You can install a time-based trigger to run the script every x minutes. I didn't have the time to add that. Let me know if you need an explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.