Get properties of a folder in Google Drive with Apps Script

Ames Computer Geek Corner New Get properties of a folder in Google Drive with Apps Script NYC New York City North Bergen County

Working with Google Drive one quickly realizes there are many good reasons to automate many tasks. Simple tasks, like creating, gathering and displaying folders is more than tedious and time consuming. Here we utilize a function from another blog 'Search for folders and display' to search for folders and permission users as Editors in my project team.

This functionality is built on top of previous blogs such as, 'Create a Folder in the Root Drive' and 'Iterate and Display folder's full path'.

I often work with data sets that are populated from a database or spreadsheets to analyze big chunks of data. This requires creation of folders and files on demand that will hold my new spreadsheets and data. The folders and files are created and manipulated dynamically; therefore the data used needs to be cleaned up and removed from my Google Drive when the process has completed. Once I have my spreadsheet or docs built out from my datasets, I automate many of the tasks using my Google Apps Script code base.

In our example we will employ the DriveApp Class to manage, create and find files and folders in Google Drive. Since we are working primarily in folder context, we will need to manipulate folders and listing files using Folder Class, which creates, deletes and manages folders and files.

Teams working on projects have different levels of permission requirements. Some team members require read only permissions, others require editing rights. If you are looking for read only viewer permissions check out my other blog: Add Viewers Permission to Folder(s)

In this blog we will focus on moving a folder from one location to another. If the searched folder is found, we will create two folders dynamically called 'test00' and 'test01'. The goal will be to move folder 'test00' into folder 'test01'.

To start, we must first search for our parent folder. The DriveApp Class function allows us to narrow down a specific set of folders using a name search: 'DriveApp.getFoldersByName("test00")'. This function returns a 'FolderIterator' object that we will use to iterate over found folders. Using the first folder found in the folder-iterator we will create the two new sub-folder.

  var folderObj = null;
  var folderNameIter = DriveApp.getFoldersByName("devel");
    folderObj =;
    var newFldrTest00 = folderObj.createFolder("test00");
    var newFldrTest01 = folderObj.createFolder("test01");

We created two new folders, we have one more step to make and that is to move 'test00' into 'test01' folder. Utilising the 'Folder Class' Api and function 'folder.moveTo()' we will move the folder 'test00' into 'test01':


If you are looking for details behind the function or the parameters to the function you can visit the Class Folder Page.