Get Google Drive Folder ID
Posted By: Harish

Previously, we have seen ways to get a google file ID. Similarly, we can get folder IDs too.
In this post, we will discuss ways to get google drive folder IDs using an URL or using a script.
Get Folder ID from its URL
If we have a google drive's folder link, we can get the folder ID easily.
Let's take a folder link as an example.
https://drive.google.com/drive/folders/1QuXvRRAJX9hHyikkkcEGWgEl7Bmlcuiz
The folder ID is the unique text after folders/
. So, from our example link, the folder ID will be 1QuXvRRAJX9hHyikkkcEGWgEl7Bmlcuiz
.
Similarly, we can easily identify any other google drive folder ID from its URL.
Get Folder ID through its name
What if you know the name of the folder and want its folder ID?
For this, we can get the ID using the folder's name by running a simple script function.
Open Google Apps Script editor and create a new project.
Replace the default function (which already exists) with the below function and run it. Visit creating and executing a Google Apps Script post for more info.
function getGoogleDriveFolderId() {
try {
const folderName = "CSV Folder" //<-- change folder name here
const folders = DriveApp.getFoldersByName(folderName);
while (folders.hasNext()) {
const folder = folders.next();
const folderId = folder.getId();
console.log(`${folderName} ID:`, folderId );
}
} catch (err) {
Logger.log(err)
}
}
By executing the above function in our google apps script project, the folder ID will be printed out in the execution log window.