SHARE
TWEET

Untitled

a guest Jul 21st, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Create folders, add one folder to another folder
  2. function example41() {
  3.   const parentFolder = DriveApp.getFolderById('ADD FOLDER ID HERE');
  4.   const folder1 = parentFolder.createFolder("EXAMPLE41-FOLDER1");
  5.   const folder2 = parentFolder.createFolder("EXAMPLE41-FOLDER2");
  6.   folder1.addFolder(folder2);
  7. }
  8.  
  9. //Get 2 folders by their IDs and remove one folder from within the other one
  10. function example42() {
  11.   const folder1 = DriveApp.getFolderById('ADD FOLDER ID HERE');
  12.   const folder2 = DriveApp.getFolderById('ADD FOLDER ID HERE');
  13.   folder1.removeFolder(folder2);
  14. }
  15.  
  16. //Create folders, create file, add file to another folder
  17. function example43() {
  18.   const parentFolder = DriveApp.getFolderById('ADD FOLDER ID HERE');
  19.   const folder3 = parentFolder.createFolder("EXAMPLE43-FOLDER3");
  20.   const folder4 = parentFolder.createFolder("EXAMPLE43-FOLDER4");
  21.   const file = folder3.createFile("EXAMPLE43-NEW FILE",
  22.                                   "This will be a file in two folders",
  23.                                   MimeType.PLAIN_TEXT);
  24.   folder4.addFile(file);
  25. }
  26.  
  27. //Create folders, create file, add file to another folder
  28. function example44() {
  29.   const folder4 = DriveApp.getFolderById('ADD FOLDER ID HERE');
  30.   const file = DriveApp.getFileById('ADD FILE ID HERE');
  31.   folder4.removeFile(file);
  32. }
  33.  
  34. //Make Google Doc, move from My Drive to folder using add and remove
  35. function example45() {
  36.   var newDoc = DocumentApp.create("EXAMPLE45-New Google Doc");
  37.   var newDoc = DriveApp.getFileById(newDoc.getId());
  38.   const parentFolder = DriveApp.getFolderById('ADD FOLDER ID HERE');
  39.   const example45Folder = parentFolder.createFolder("EXAMPLE45");
  40.   example45Folder.addFile(newDoc);
  41.   DriveApp.removeFile(newDoc);
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top