0

I wrote a very bad script to automate the creation of a project folder structure in Google appscript. I understand that I have to have the Advanced Drive Service enabled. (Which I do) and I that I need to include the query parameter {supportsAllDrives=true} in my script but I just do not know how to incorporate it.

My script is essentially creating folders and it's sub folders and nesting those folders and making copies of files and placing them in those folders. The code I put is only for one of the many folders that need to be created. If I can understand how to use the supportsAlldrives=true argument I can go an apply to the rest of the script.

I'm just not sure on where to insert the query parameter of "supports all drives". I have the Api enabled.

Where and how do I insert the support all drives argument?

function siteBuild() {
  var fldrname= SpreadsheetApp.getActiveSpreadsheet().getRange("D2").getValue();
  var mainFolder = DriveApp.createFolder(fldrname).getId();
  var finaldestination = DriveApp.getFolderById(mainFolder);
  //Creates First Layer of Folders
  var allFolders =["0.FDOB Newsletter + UX Survey","1.Cost Control","2.Network + Low Voltage","3.Audio Visual","4.Construction Docs","5.Schedules","1.Circuit Information","2.Design","3.Installation & Commissioning","4.Photos","5.As Builts","1. Communications Sent (Email,Template)","2. UX Survey and Results","Heatmaps","Final","Installation","Site Survey","1.Design","2.Installation & Commissioning","3.Photos","4.As Builts","Architecturals + Schematics","Programming Files"]
  var dest = DriveApp.createFolder(allFolders[0]).getId();
  var fdob1 = DriveApp.createFolder(allFolders[11]).getId();
  var fdob2 = DriveApp.createFolder(allFolders[12]).getId();
  //Creates & Moves "0.FDOB Newsletter + UX Survey"
  var fdobfldrs1 = DriveApp.getFolderById(fdob1);
  var fdobfldrs2 = DriveApp.getFolderById(fdob2);
  var destination = DriveApp.getFolderById(dest);
  fdobfldrs1.moveTo(destination);
  fdobfldrs2.moveTo(destination);

Thank you!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
uhsleep
  • 21
  • 2
  • https://stackoverflow.com/questions/62403468/shared-drive-support-in-google-apps-script – Cooper Feb 26 '23 at 18:19
  • I think that in the current stage, when the file ID and the folder ID are used, the files and folders in the shared drive can be managed by the Drive service (DriveApp). From this situation, when I saw your question and script, your script uses the folder IDs and I cannot understand the current issue of your script. I apologize for my poor English skill. Can I ask you about the detail of your current issue? For example, if a folder in your Drive cannot be moved to the shared Drive by `fdobfldrs1.moveTo(destination);`, please test `destination.createFolder(allFolders[11])`. – Tanaike Feb 27 '23 at 00:02
  • By directly creating the new folder, the script might be able to be worked. But, in this case, you are required to have the write permission to the shared Drive. Please be careful about this. – Tanaike Feb 27 '23 at 00:08

0 Answers0