
Results = DRIVE_SERVICE.files().list(q="mimeType='application/' and parents in '"+folder_id+"' and trashed = false",fields="nextPageToken, files(id, name, createdTime)", orderBy="createdTime").execute() To determine the name of latest file uploaded in the GDrive folder, use the getLatestFile() and retrieveName() methods: def getLatestFile(folder_id): Results = DRIVE_SERVICE.files().list(q="mimeType='application/' and parents in '"+folder_id+"' and trashed = false",fields="nextPageToken, files(id, name)").execute() To determine the number of files in a GDrivefolder, use the countFiles() method: def countFiles(folder_id): Results = DRIVE_SERVICE.files().list(q="mimeType='application/' and parents in '"+folder_id+"' and trashed = false",fields="nextPageToken, files(id, name)",pageSize=400).execute() Retrieve the basic folder information (folder id and name) using this Google API query: def getAllFolders(folder_id, spreadsheet_id): Image: Desired Output in Google Spreadsheet In this scenario, I wanted to know the following: Step 1: Get all the folders in Google Drive.Īgain before we start, you must know how to connect to Google APIs already, which I discussed in this demo.įirst, list down the information you need to extract from GDrive API. Write to Google Spreadsheet and Customize the format - Click here Get all the folders in Google Drive - Click here A Google spreadsheet to list your output.A Google Drive folder that you want to track.It's inconvenient to list the uploaded folders one by one. I personally use this script right after uploading hundreds of files to GDrive for monitoring purposes. Upload Excel files to Google Drive: Part 1 and Part 2īefore proceeding with this tutorial, make sure you have read and understood my previous posts.Split a huge Excel workbook into multiple files: Click here.This post is part of the Project Pigeon, a series of tutorials that covers using Python to automate the following tasks: To keep track of all your folders and files in Google Drive, you can run a Python script that automatically scrapes information of all the content uploaded in your account. List your folders in Google Drive using Python python, analytics, pigeon, automation, code, work, Google APIs, demo
