You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何拆分Google幻灯片并按指定文件名保存到指定文件夹

Google幻灯片按指定名称拆分并保存到指定文件夹

需求说明

需要将Google幻灯片拆分为单页独立文件,要求:

  • 依据电子表格指定范围的内容为每张拆分后的幻灯片命名
  • 将所有拆分文件保存到指定的云端硬盘文件夹

修改后的脚本

function splitSlidesWithCustomNames() {
  // 请替换为你的幻灯片ID、电子表格ID、名称范围、目标文件夹ID
  const presentationId = "###"; 
  const spreadsheetId = "###";
  const range = "A1:A"; // 电子表格中存储幻灯片名称的范围,比如A1到A列所有有内容的单元格
  const folderId = "###";

  // 获取电子表格中的命名列表
  const names = SpreadsheetApp.openById(spreadsheetId)
    .getRange(range)
    .getValues()
    .flat()
    .filter(name => name); // 过滤空值

  // 获取目标文件夹
  const targetFolder = DriveApp.getFolderById(folderId);

  // 拆分幻灯片
  const originalSlides = SlidesApp.openById(presentationId).getSlides();
  originalSlides.forEach((slide, index) => {
    // 用对应名称命名,若没有对应名称则用默认命名
    const slideName = names[index] || `page${index + 1}`;
    // 创建新幻灯片
    const newPresentation = SlidesApp.create(slideName);
    // 添加目标幻灯片并删除默认空白页
    newPresentation.appendSlide(slide);
    newPresentation.getSlides()[0].remove();
    // 将新文件移动到指定文件夹
    const file = DriveApp.getFileById(newPresentation.getId());
    file.moveTo(targetFolder);
  });
}

使用步骤

  • 打开Google Apps脚本编辑器,替换脚本中所有###对应的ID和范围
  • 运行splitSlidesWithCustomNames函数,首次运行需授权脚本访问权限

内容的提问来源于stack exchange,提问作者d-ron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 06:40:46