IMDbMovieFileFixer is a Python script designed to streamline and enhance your movie file organization. This tool automatically renames movie files in a specified folder to a standardized format, corrects common grammar mistakes, and verifies movie titles against official names on IMDb. Unlike similar tools like movie-file-fixer or imdb-rename, it emphasizes grammar correction and detailed logging for transparency, making it ideal for movie enthusiasts and collectors.
- Standardized Renaming: Renames movie files to a consistent format including the release year (e.g., "Movie Title (2023).mp4").
- Grammar Correction: Fixes common grammar mistakes in movie titles (e.g., "Dont" to "Don't").
- Cleanup: Removes unnecessary information (e.g., resolution, codec) from filenames.
- IMDb Verification: Cross-checks titles with IMDb and logs discrepancies.
- Duplicate Handling: Appends an index to duplicate filenames (e.g., "Movie (2023) [1].mp4").
- Detailed Logging: Generates a log file detailing all changes, discrepancies, and errors.
- Python 3.6 or higher: Download from python.org if not installed. Check your version with
python --version
. - Git: Required to clone the repository. Install from git-scm.com if needed.
To avoid dependency conflicts, use a virtual environment:
-
Create a virtual environment:
python -m venv env
-
Activate it:
- Windows:
env\Scripts\activate
- Unix/Linux/Mac:
source env/bin/activate
Install the necessary Python libraries using pip
:
pip install requests beautifulsoup4
-
Clone the repository:
git clone https://github.com/MichalAFerber/IMDbMovieFileFixer.git
-
Navigate to the project directory:
cd IMDbMovieFileFixer
Alternatively, download the script directly from the GitHub repository.
-
Set the Folder Path: Open
IMDbMovieFileFixer.py
in a text editor and set thefolder_path
to your movie directory:folder_path = "/path/to/your/movie/folder"
-
Run the Script: In the terminal, navigate to the project directory and execute:
python IMDBMovieFileFixer.py
-
Review the Log File: Check the generated log file (e.g.,
_output 2024-12-23 23-40-15.txt
) in the project directory for details on changes and discrepancies.
Note: Back up your movie files before running the script to prevent accidental data loss. For large collections, process in smaller batches to avoid IMDb rate limits.
Customize the script by modifying IMDbMovieFileFixer.py
:
- Renaming Format: Adjust the
rename_format
variable to change the output format (default: "{title} ({year}).{ext}"). - Grammar Rules: Edit the
correct_grammar
function to add or remove grammar corrections (e.g., change "Dont" to "Don't" or add new patterns). - IMDb Request Delay: Modify
time.sleep(1)
to increase the delay between IMDb requests (e.g.,time.sleep(2)
for rate limit issues).
The script generates a log file in the project directory, named with the current date and time (e.g., _output 2024-12-23 23-40-15.txt
). It includes:
- Renamed files and their new names.
- Duplicate filenames and how they were handled.
- Official IMDb names and any discrepancies.
- Errors encountered during processing.
Millers.2013.1080p.BluRay.x264.YIFY.mp4
Dont.Breathe.2016.720p.WEBRip.x264.AAC-ETRG.mkv
Miller's (2013).mp4
Don't Breathe (2016).mkv
The script processes common video file extensions: .mp4
, .mkv
, .avi
, .mov
, .wmv
. Other file types in the folder are ignored.
- Python Version Error: Ensure Python 3.6+ is installed (
python --version
). - Missing Libraries: Run
pip install requests beautifulsoup4
to install dependencies.
- Folder Path Issues: Verify the
folder_path
exists and you have read/write permissions. - File Not Found: Ensure files aren’t being moved or deleted during script execution.
- Permission Denied: Run the script with elevated privileges (e.g.,
sudo python IMDbMovieFileFixer.py
on Unix).
- Rate Limiting: Increase the delay in
time.sleep(1)
totime.sleep(2)
or higher. - Search Issues: Check your internet connection and IMDb accessibility. Update the
search_imdb
function’s URL or headers if IMDb’s structure changes. - Multiple Results: The script uses the first IMDb result. Enhance the
search_imdb
function for better filtering if needed.
- Incorrect Filename Format: Ensure filenames include the movie name and year. Adjust the regex in the script for custom formats.
- Encoding Issues: Use UTF-8 encoding for files (e.g.,
open(filename, 'r', encoding='utf-8')
). - Special Characters: The script handles most special characters, but add custom handling in the renaming logic if issues arise.
Q: What happens if there’s a duplicate filename?
A: The script appends an index (e.g., "Movie (2023) [1].mp4") to ensure uniqueness".
Q: Can I use this for TV shows or other media?
A: The script is designed for movies. TV show support requires modifications to handle episodic naming.
Q: Does it support non-English movie titles?
A: Yes, but ensure IMDb has the title. Special characters are handled, but complex cases may need custom logic.
Q: What file formats are supported?
A: Supports .mp4
, .mkv
, .avi
, .mov
, .wmv
. Contact the maintainer for additional formats.
Q: Can I customize the renaming format?
A: Yes, modify rename_format
in the script (e.g., "{title} [{year}]").
Q: How do I change the delay between IMDb requests?
A: Adjust time.sleep(1)
in the script to a higher value (e.g., time.sleep(2)
).
Q: What if IMDb’s website changes?
A: Update the search_imdb
function’s BeautifulSoup selectors to match IMDb’s new structure.
Q: How do I preview changes before renaming?
A: If IMDb changes its website structure, the script might need updates to the HTML parsing logic. Check the search_imdb
function and adjust the BeautifulSoup selectors accordingly.
Q: How do I revert changes?
A: Use the log file to manually rename files back. Automating reversion requires additional scripting.
Contributions are welcome! To contribute:
- Fork the repository.
- Follow PEP 8 coding standards.
- Test changes locally with a sample movie folder.
- Submit a pull request with a clear description of your changes.
For major changes, open an issue first to discuss with the maintainer.
This tool uses IMDb data for title verification. Ensure compliance with IMDb’s Conditions of Use. Avoid excessive requests to prevent rate limiting.
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
For support or questions, contact the maintainer via GitHub Issues.