Giter VIP home page Giter VIP logo

dearborn-enterprises / gdrive-folders-organizer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from illia-the-coder/gdrive-folders-organizer

0.0 0.0 0.0 6 KB

This Jupyter notebook helps organize files in a Google Drive directory based on their file extensions. Files will be sorted into predefined categories depending on their types (documents, multimedia files, code files, etc.).

Jupyter Notebook 100.00%

gdrive-folders-organizer's Introduction

GDrive-Folders-organizer

File Organization in Google Drive

This Jupyter notebook helps organize files in a Google Drive directory based on their file extensions. Files will be sorted into predefined categories depending on their types (documents, multimedia files, code files, etc.).

Requirements

This script uses Google Colab and requires the following libraries:

  • os (built-in)
  • shutil (built-in)
  • tqdm

To install tqdm, run the following command:

!pip install tqdm 

Instructions

Step 1: Mount Google Drive folder to Google Colab

Before starting file organization, mount your Google Drive folder to Google Colab by running the following code:

from google.colab import drive
drive.mount('/content/drive')

Step 2: Install tqdm library

We will use the tqdm library to display a progress bar during file iteration. Install and import the necessary libraries using this code:

!pip install tqdm
import os
import shutil
from tqdm import tqdm

Step 3: Get Unique File Extensions

The get_unique_file_extensions function walks through the directory structure of a given source folder and identifies unique file extensions.

def get_unique_file_extensions(src_folder):
    # code block here

Run this function and print unique file extensions found in your Google Drive folder:

source_folder = "/content/drive/MyDrive"
unique_extensions = get_unique_file_extensions(source_folder)
print(unique_extensions)

Step 4: File Categories

Define a dictionary mapping file extensions to categories. This will serve as the guide for the categorization process.

file_categories = {
    # list of categories here
}

Step 5: Categorize Files

The categorize_files function goes through the directory structure, moving files into the appropriate category folders based on their extensions.

def categorize_files(src_folder, file_categories=file_categories, go_through=True):
    # code block here

Step 6: Implement File Sorting

Finally, run the categorize_files function to sort all files in your Google Drive:

source_folder = "/content/drive/MyDrive"
categorize_files(source_folder)

This will sort files into category-specific directories within the source folder. Please note that any files with extensions not defined in the file_categories dictionary will be moved to an 'Others' directory.

Caution

Please backup your data before running this script, as moving files could result in data loss if not handled properly. We are not responsible for any data loss that may occur.

Contributions

Suggestions and improvements are welcome. Feel free to submit a pull request.

gdrive-folders-organizer's People

Contributors

illia-the-coder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.