Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get folder ID by its name
// Get the *first* folder ID by its name
function getFolderByName(folderName) {
var folders = DriveApp.getFoldersByName(folderName);
var folderID = null;
if (folders.hasNext())
folderID =;
return folderID;
if you have multiple folders with the same name, you would have
to iterate through them in a while loop similar to the file
iterator in the code you linked) and find a marker that proves
this is the folder you are looking for (i.e. you could have an
empty file with a particular name in there)
-- patt0

This comment has been minimized.

Copy link

eebanos commented Jan 31, 2015

This isn't working for me, it works if you change line 7 as follows: folderID =;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.