Skip to content

Python script that generates a CSV file containing the directory tree and information about files and folders in a specified folder on your Google Drive.

License

Notifications You must be signed in to change notification settings

4-alok/gdive_path_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate Google Drive Directory Tree and File List

This Python script uses the Google Drive API to generate a list of files and folders in a specified directory tree, including their full path, name, type, date, URL, last updated, description, size, and owner email.

Prerequisites

To use this script, you need to have the following:

A Google Drive account with the necessary permissions to access the directory you want to list.

* A Google Cloud Console project with the Google Drive API enabled.
* OAuth2 credentials to authenticate and authorize the application to access your Google Drive. Follow these steps to obtain the credentials.json file:
    * Go to the Google Cloud Console (https://console.cloud.google.com/).
    * Create a new project or select an existing project.
    * Click on the "APIs & Services" menu on the left-hand side, then click on "Dashboard".
    * Click on "+ ENABLE APIS AND SERVICES" and search for "Google Drive API".
    * Click on "Enable".
    * Click on "Credentials" on the left-hand side, then click on Create "credentials" and select "OAuth client ID".
    * Choose "Desktop app" as the application type and give it a name.
    * Click on "Create" and then on "OK".
    * Click on the "Download" button next to the client ID to download the credentials as a JSON file.
    * rename the file to "credentials.json"
    * Save the file as "credentials.json" in your project directory.
    * Then run the get_token.py script to get the access token
    * Then run gdrive_path_generator.py

How to use

Update the FOLDER_ID and PATH variables with the ID of the folder you want to list and the path where you want to save the results. Run the script using Python 3.

The CSV file generated by the script contains information about the files and folders in the specified directory tree. The first row contains the column headers, and each subsequent row represents a file or folder in the directory tree. The columns contain the following information:

* Path: the full path to the file or folder, relative to the root of your Google Drive.
* Name: the name of the file or folder.
* Type: the MIME type of the file or folder, or "Folder" if it is a folder.
* Date: the date and time when the file or folder was created.
* URL: the URL where the file or folder can be accessed on Google Drive.
* Last Updated: the date and time when the file or folder was last modified.
* Description: a description of the file or folder, if available.
* Size: the size of the file in bytes, if available.
* Owner Email: the email address of the owner of the file or folder.

See the demo in demo.csv files

Disclaimer

This script is provided as-is and without warranty. Use at your own risk.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Python script that generates a CSV file containing the directory tree and information about files and folders in a specified folder on your Google Drive.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published