SHARE
TWEET

Untitled

a guest Jul 21st, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Create folder within a folder
  2. function example21() {
  3.   const folder = DriveApp.getFolderById('ADD FOLDER ID HERE');
  4.   folder.createFolder('EXAMPLE 21 FOLDER');
  5. }
  6.  
  7. //Create file in a folder
  8. function example22() {
  9.   const folder = DriveApp.getFolderById('ADD FOLDER ID HERE');
  10.   folder.createFile('EXAMPLE 22 FILE', 'This is a new file.', MimeType.PLAIN_TEXT);  
  11. }
  12.  
  13. //Create file in newly created folder
  14. function example23() {
  15.   const folder = DriveApp.getFolderById('ADD FOLDER ID HERE');
  16.   const newFolder = folder.createFolder('EXAMPLE 23 SUB FOLDER');
  17.   newFolder.createFile('EXAMPLE 23 FILE', 'This is a new file.', MimeType.PLAIN_TEXT);
  18. }
  19.  
  20. //Get URL and name of new folder, star it, add URL in text file
  21. function example24() {
  22.   const folder = DriveApp.getFolderById('ADD FOLDER ID HERE');
  23.   const newFolder = folder.createFolder('EXAMPLE 24 SUB FOLDER');
  24.   const newFolderUrl = newFolder.getUrl();
  25.   const newFolderName = newFolder.getName();
  26.   newFolder.setStarred(true);
  27.   newFolder.createFile(newFolderName,
  28.                        "New folder URL: "+newFolderUrl,
  29.                        MimeType.PLAIN_TEXT);
  30. }
  31.  
  32. //Get URL and name of new folder, star it, add URL in text file (linked const & chaining)
  33. function example24b() {
  34.   const folder = DriveApp.getFolderById('ADD FOLDER ID HERE'),
  35.         newFolder = folder.createFolder('EXAMPLE 24 SUB FOLDER'),
  36.         newFolderUrl = newFolder.getUrl(),
  37.         newFolderName = newFolder.getName();
  38.   newFolder.setStarred(true)
  39.            .createFile(newFolderName,
  40.             "New folder URL: "+newFolderUrl,
  41.              MimeType.PLAIN_TEXT);
  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