This project provides a set of asynchronous Python functions to organize, process, and clean up files and directories. It includes features such as file normalization, archive extraction, directory cleanup, and logging of file extensions.
- File Normalization: Normalizes file names by replacing Cyrillic characters with Latin equivalents and replacing non-alphanumeric characters with underscores.
- Archive Extraction: Extracts files from archives and organizes them into subdirectories named after the archive.
- Directory Cleanup: Recursively removes empty directories and handles read-only files during deletion.
- File Organization: Moves files to specific directories based on their extensions.
- Logging: Logs the structure of directories and counts file extensions for analysis.
-
Install Dependencies: This project uses Poetry for dependency management. Follow these steps to set up the environment: Install Poetry (if not already installed):
pip install poetry
-
Clone the repository (if you haven't already): Ensure you have Python 3.7+ installed. Install the required libraries using:
git clone https://github.com/MykolaMS9/folder_organizer.git cd file-organizer -
Set up the virtual environment and install dependencies: Run the following command to create a virtual environment and install all required dependencies:
poetry install
-
Activate the virtual environment: After installing dependencies, activate the virtual environment:
poetry shell
-
Verify installation: Ensure all dependencies are installed correctly by running:
poetry check
Here’s how you can install and set up the project using Poetry:
# Clone the repository
git clone https://github.com/your-repo/file-organizer.git
cd file-organizer
# Install dependencies using Poetry
poetry install
# Activate the virtual environment
poetry shell
# Run the project
python main.py- Run program with
python main.pypython main.py
- Specify the path to the directory containing the files to be organized and processed.
Write path to clean or 'exit' -> C:\Users\YourName\Documents\TestFolder
- The program will process the files and organize them into subdirectories based on their extensions.
---------------------------------------------------------------------------------------------------- Moved files: C:\Users\YourName\Documents\TestFolder\text_files\file1.txt C:\Users\YourName\Documents\TestFolder\images\photo1.jpg ---------------------------------------------------------------------------------------------------- Removed from pc: C:\Users\YourName\Documents\TestFolder\empty_folder ---------------------------------------------------------------------------------------------------- Extensions of exists files: text_files: .txt 5 images: .jpg 3
Full documentation is available by sending: Documentation
Normalizes a file name by replacing Cyrillic characters with Latin equivalents and non-alphanumeric characters with underscores.
Renames a file by incrementing a numeric suffix or adding a new one if it doesn't exist.
Moves a file to a target directory, ensuring the file name is normalized and unique.
Extracts files from archives in a specified directory and organizes them into subdirectories.
Handles the removal of read-only files or directories by changing their permissions and retrying the operation.
Asynchronously removes a directory tree, handling read-only files or directories.
Recursively logs the contents of a directory and counts the occurrences of each file extension.
Recursively processes files and directories, moving files based on their extensions and deleting empty directories.
The main function that orchestrates file processing, including reading folders, unzipping archives, moving files, and logging results.