Google Apps Script Learn Coding Projects Exercises Resources

Explore how you can get started with Google Apps Script using code to interact with Google Workspace GSuite Apps
4.50 (6 reviews)
Udemy
platform
English
language
Programming Languages
category
instructor
Google Apps Script Learn Coding Projects Exercises Resources
158
students
17 hours
content
Jun 2025
last update
$29.99
regular price

Why take this course?

您提供的内容是关于在Google Apps Script中使用不同的服务(如DriveApp, DocumentApp, SpreadsheetApp, GmailApp, SlidesApp等)来执行各种操作的概述。以下是针对您提到的每个主题的详细解释:

  1. Select all the editors of a folder: 使用Drive.Files.list来获取一个文件夹中所有文件的Iterator,然后循环通过DriveUser对象获取每个编辑者的信息。
var folder = DriveApp.getFolderById('your-folder-id');
var filesIterator = folder.getFiles();
while (filesIterator.hasNext()) {
  var file = filesIterator.next();
  var editors = file.getEditors();
  for (var i = 0; i < editors.length; i++) {
    Logger.log('Editor ' + (i + 1) + ': ' + editors[i].getEmail());
  }
}
  1. Get the email of the editor from the DriveUser object: 在上面的循环中,我们已经获取了每个编辑者的电子邮件。

  2. Get all the folders from a selected folder: 使用DriveApp.getFolders()来获取一个文件夹下的所有子文件夹。

var parentFolder = DriveApp.getFolderById('your-folder-id');
var childFoldersIterator = parentFolder.getFolders();
while (childFoldersIterator.hasNext()) {
  var childFolder = childFoldersIterator.next();
  Logger.log(childFolder.getName());
}
  1. Create files adding editors to the file that gets created: 使用DocumentApp.create()来创建文件,并设置编辑者。
var newDoc = DocumentApp.create('New Document');
var editorEmail = 'editor@example.com';
var editor = Session.getEffectiveUser();
editor.addEditor(newDoc, editorEmail);
  1. Setting a file type with MimeType and file extension in the name: 在创建文件时,确保指定正确的MIME类型和文件扩展名。
var newFile = DriveApp.createFile('newfile.txt');
newFile.setName('newfile.pdf');
newFile.setMimeType(DocumentApp.MimeType.PDF);
  1. Create Move Updates Files and Folders within your Google Drive with Code: 使用相应的类(如DriveApp, DocumentApp, SpreadsheetApp等)来创建、移动和更新文件和文件夹。

  2. How to add email attachments to your drive with Apps Script: 使用GmailApp来获取电子邮件附件,并将它们保存到驱动中。

var thread = GmailApp.getThreadById('your-thread-id');
var messages = thread.getMessages();
for (var i = 0; i < messages.length; i++) {
  var attachments = messages[i].getAttachments();
  for (var j = 0; j < attachments.length; j++) {
    var blob = attachments[j].getBlob();
    DriveApp.createFile(blob).setName(attachments[j].getName());
  }
}
  1. Explore Slides Service with SlidesApp Class with Apps Script code: 使用SlidesApp来创建、编辑和操作Google幻灯片文件。
var newPresentation = SlidesApp.create('New Presentation');
var slide = newPresentation.duplicateSlide(0); // Duplicates the first slide
slide.insertShapeText(1, 1, 'Text Shape'); // Adds a shape with text at position (1, 1) on the duplicated slide
  1. How to generate images from all the slides in your presentation and save the images to your drive: 循环通过SlidesApp获取幻灯片,并为每个幻灯片创建图像。
var presentation = SlidesApp.openById('your-presentation-id');
var slides = presentation.getSlides();
for (var i = 0; i < slides.length; i++) {
  var slideImageBlob = slides[i].as(MimeType.IMAGE);
  DriveApp.createFile('slide' + (i + 1) + '.jpg').setContent(slideImageBlob);
}

这些步骤概述了在Google Apps Script中使用不同服务的基本操作。您可以根据需要进一步探索和实现这些功能。

Course Gallery

Google Apps Script Learn Coding Projects Exercises Resources – Screenshot 1
Screenshot 1Google Apps Script Learn Coding Projects Exercises Resources
Google Apps Script Learn Coding Projects Exercises Resources – Screenshot 2
Screenshot 2Google Apps Script Learn Coding Projects Exercises Resources
Google Apps Script Learn Coding Projects Exercises Resources – Screenshot 3
Screenshot 3Google Apps Script Learn Coding Projects Exercises Resources
Google Apps Script Learn Coding Projects Exercises Resources – Screenshot 4
Screenshot 4Google Apps Script Learn Coding Projects Exercises Resources

Loading charts...

4472608
udemy ID
02/01/2022
course created date
21/01/2022
course indexed date
Bot
course submited by