3
votes

Is there a way to create a google app script to create a new folder in Google Drive that is NOT IN THE ROOT FOLDER? A script to move a folder in the root to a particular folder will also do.

4
search this forum as it has been asked answered beforeZig Mandel
You should google for answers before asking. Here's the duplicate: GAS-create-folderSujay Phadke

4 Answers

12
votes
var parentFolder=DriveApp.getFolderById(parentFolderId);
var newFolder=parentFolder.createFolder("My New Folder Name")
2
votes
var parentFolder=DriveApp.getFolderById(DriveApp.getRootFolder().getId());
  var newFolder=parentFolder.createFolder("name folder")
0
votes

The folder object has a createFolder method, see doc here. so you should simply get the folder you want and create the new one from there.

0
votes

If you are going to need the folder ID to let's say move or create a file there you can do the following.

var parentFolder = DriveApp.getFolderById(parentFolderId);
var newFolderID = parentFolder.createFolder("New Folder Name").getId();

Then you can do this

DriveApp.getFolderById(newFolderID);