Reputation: 1
I create a google doc file and populate it from a presentation's notes. However, it puts the file in my root directory and not the directory of the presentation which is in a shared drive folder. I tired to move it but that did not work. Is there a way to create the document in the same folder as the slides? I have the folder ID. The code that I use to create it is:
`your text` let docname = SlidesApp.getActivePresentation().getName();
`your text` let doc = DocumentApp.create("Slide Notes - " + docname);
`your text` let body = doc.getBody();
I then put the notes from each slide into body
I tried moving it but it did not move. addfile and removefile no longer works
Upvotes: 0
Views: 179
Reputation: 201583
I believe your goal is as follows.
In this case, how about the following sample script?
const s = SlidesApp.getActivePresentation();
const fileId = s.getId();
const file = DriveApp.getFileById(fileId);
const parent = file.getParents().next();
let docname = s.getName();
let doc = DocumentApp.create("Slide Notes - " + docname);
DriveApp.getFileById(doc.getId()).moveTo(parent);
let body = doc.getBody();
When this script is run, a new Google Document is created in the same folder of the parent folder of the active Presentation.
As another approach, in this pattern, Drive API is used. So, please enable Drive API v3 at Advanced Google services.
const s = SlidesApp.getActivePresentation();
const fileId = s.getId();
const file = DriveApp.getFileById(fileId);
const parent = file.getParents().next();
const parentFolderId = parent.getId();
let docname = s.getName();
const { id } = Drive.Files.create({ name: "Slide Notes - " + docname, parents: [parentFolderId], mimeType: MimeType.GOOGLE_DOCS }, null, { supportsAllDrives: true });
let doc = DocumentApp.openById(id);
let body = doc.getBody();
Upvotes: 0