Music Renamer & Organizer



This application automates the process of organizing your music library. It scans audio files in a specified input folder, uses the Gemini AI to identify the correct artist, title, year, album, and track number, and then renames the files and updates their internal metadata (tags). Finally, the organized files are copied to an output folder, sorted according to your preferences.

 

The application consists of three Python scripts:

  • music_renamer.py: A startup GUI that checks for and installs necessary dependencies (google-generativeai, mutagen) and then launches the main application.

  • rename_music_gui.py: The main graphical user interface, allowing you to monitor the process. The input and output folders are currently hardcoded for simplicity.

  • rename_music_logic.py: The core logic that handles file scanning, communication with the Gemini AI, metadata updating, and file organization.


Features

  • AI-Powered Metadata: Uses Google's Gemini AI to accurately find song metadata, even from messy filenames.

  • Comprehensive Tagging: Updates essential tags including title, artist, album, release year, and track number.

  • Intelligent Sorting: Automatically organizes files into a clean folder structure. You can subdivide by artist (e.g., /Artist Name/), album (e.g., /Artist Name/Album Name/), or individual year (e.g., /2009/).

  • Broad Format Support: Works with a wide range of audio formats like MP3, M4A, FLAC, WMA, OGG, and more.

  • User-Friendly GUI: A simple graphical interface shows the progress and logs all operations in real-time.

  • Dependency Management: An automatic startup checker installs required Python packages for you.


Prerequisites

  • Python 3: Ensure Python is installed on your system.

  • PIP: Python's package installer, which is usually included with Python.

  • Gemini API Key: You must have an API key from Google AI Studio.


How to Use

  1. Set API Key: Before running the application, you must set your Gemini API key as an environment variable.

    • Windows:

      setx GEMINI_API_KEY "YOUR_API_KEY"

      (Note: You may need to restart your command prompt or your computer for this to take effect.)

    • macOS/Linux:

      export GEMINI_API_KEY="YOUR_API_KEY"

      (Add this line to your ~/.bashrc, ~/.zshrc, or shell configuration file to make it permanent.)

 

Configure Folders

Open the rename_music_gui.py file and modify the following lines to set your desired input and output directories:

self.input_folder = tk.StringVar(value=r"C:\Path\To\Your\Input\Music") self.output_folder = tk.StringVar(value=r"C:\Path\To\Your\Output\Music")

 

Run the Application: Execute the startup script from your terminal:

python "music renamer.py"

The startup checker will first appear, install any missing packages, and then launch the main application window.

 

Start Processing

  • Review the pre-filled input and output paths in the GUI.

  • Select your desired options (e.g., include subfolders, subdivide by year).

  • Click the "Start Processing" button.

  • The log window will display the progress of each file being processed. Processed files will be copied to your output folder, and any files that fail will be moved to an "Failed Music" subfolder within your output directory.


License

This project is licensed under the GNU General Public License v3.0.

For the full license text, see the LICENSE file or visit the GNU website.