Created
October 6, 2023 10:52
-
-
Save phillypb/488c22c061c0bfb2b7d0268ad768af8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Developed by The Gift of Script: https://www.pbainbridge.co.uk/ | |
*/ | |
function getFileInfo() { | |
// ID of the folder to scan for files | |
var folderId = "ENTER YOUR FOLDER ID HERE"; | |
// create the parameters for accessing the Drive API and extracting specific information | |
var payload = | |
{ | |
'q': `'${folderId}' in parents and trashed=false`, | |
'fields': `items(title, mimeType, id, createdDate, modifiedDate, alternateLink, owners)`, | |
'supportsAllDrives': true, | |
'includeItemsFromAllDrives': true | |
}; | |
// call the Drive API | |
var response = Drive.Files.list(payload); | |
// get the file item details specifically from the result | |
var fileItems = response.items; | |
// loop through each file in the folder *************************** | |
for (var i = 0; i < fileItems.length; i++) { | |
// get individual details for a single file | |
var fileInfo = fileItems[i]; | |
console.log("File info is: " + fileInfo); | |
// get all owners of the file | |
var allOwners = fileInfo.owners; | |
console.log("allOwners is: " + allOwners); | |
// convert the data to a JavaScript Object so it can be queried | |
var cleanData = JSON.parse(allOwners); | |
console.log(cleanData); | |
// get the email address of the owner | |
var ownerEmailAddress = cleanData.emailAddress; | |
console.log("ownerEmailAddress is: " + ownerEmailAddress); | |
}; | |
// loop through each file in the folder *************************** | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment