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.
-
search this forum as it has been asked answered beforeZig Mandel– Zig Mandel2017-01-14 12:34:57 +00:00Commented Jan 14, 2017 at 12:34
-
You should google for answers before asking. Here's the duplicate: GAS-create-folderSujay Phadke– Sujay Phadke2017-01-15 08:01:02 +00:00Commented Jan 15, 2017 at 8:01
-
Possible duplicate of Create new file in a folder with Apps Script using Google Advanced Drive serviceSujay Phadke– Sujay Phadke2017-01-15 08:01:23 +00:00Commented Jan 15, 2017 at 8:01
-
look at this one : stackoverflow.com/questions/11910734/…Serge insas– Serge insas2017-01-15 11:05:40 +00:00Commented Jan 15, 2017 at 11:05
Add a comment
|
5 Answers
var parentFolder=DriveApp.getFolderById(DriveApp.getRootFolder().getId());
var newFolder=parentFolder.createFolder("name folder")
1 Comment
Samuel Philipp
Welcome to Stack Overflow! While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
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);
Comments
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.