Tools to manage and remove oversized media files from your Sonarr and Radarr libraries. Perfect for users who have adjusted their quality settings and need to clean up existing large files.
arr-shrink permanently deletes media files from your disk.
- Deleted files cannot be recovered without backups
- Always test with dry-run mode first
- Consider backing up important files before execution
- Understand that re-downloads depend on availability - if files are no longer available from your indexers, they may be permanently lost
- This process is irreversible - make sure you understand what will be deleted
- Python 3.6 or higher
- Sonarr v3 or Radarr v3 (API v3 compatibility required)
- Network access to your Sonarr/Radarr instance
- File system access to your media library
- Valid API keys for your applications
- Sonarr: v3.x and newer (uses API v3 endpoints)
- Radarr: v3.x and newer (uses API v3 endpoints, confirmed working on v5.x)
- Python: 3.6+ required, tested on 3.8-3.11
- OS: Windows 10+, macOS 10.14+, Linux (most distributions)
- You've changed quality profiles to prefer smaller file sizes
- You want to replace large 4K files with more reasonable 1080p versions
- You need to free up disk space by removing unnecessarily large files
- You're tired of manually deleting files to trigger re-downloads
These tools automate the process of identifying and removing oversized media files so Sonarr and Radarr can download replacements according to your current quality settings.
- Size-Based Targeting: Identifies files exceeding your specified size threshold
- Safe Execution: Runs in dry-run mode by default to preview changes
- Path Verification: Includes a utility to test path conversion settings
- Batch Processing: Controls the deletion pace to prevent system overload
- Processing History: Tracks deleted files to prevent reprocessing
- Detailed Logging: Shows exactly what's happening at each step
- Cross-Platform: Works on Windows, macOS, and Linux
- Download the scripts from this repository
- Install dependencies:
pip install requests
- Configure the scripts by editing the settings at the top of each file
Sonarr:
- Go to Settings → General
- Copy the API Key value
Radarr:
- Go to Settings → General
- Copy the API Key value
Edit the configuration section at the top of each script:
# Sonarr/Radarr connection details
SONARR_URL = 'http://xxx.xxx.xxx.xxx:8989' # Your Sonarr URL
RADARR_URL = 'http://xxx.xxx.xxx.xxx:7878' # Your Radarr URL
API_KEY = 'xxxxxx' # Your API key
# File size threshold
MAX_SIZE_GB = 4.0 # Maximum episode size in GB (Sonarr)
MAX_SIZE_GB = 10.0 # Maximum movie size in GB (Radarr)
# Processing options
BATCH_SIZE = 5 # Number of files to process in each batch
DELAY_SECONDS = 10 # Delay between batches in secondsThe most critical configuration is the MEDIA_PATH_PREFIX setting, which tells the script how to access your media files.
Windows - Local Media:
MEDIA_PATH_PREFIX = "C:\\Media\\TV Shows\\" # Local drive
MEDIA_PATH_PREFIX = "D:\\Plex\\TV Shows\\" # Different driveWindows - Network Share:
MEDIA_PATH_PREFIX = "\\\\192.168.1.100\\media\\TV Shows\\" # IP address
MEDIA_PATH_PREFIX = "\\\\MediaServer\\shares\\TV Shows\\" # Server nameLinux/Mac - Local Media:
MEDIA_PATH_PREFIX = "/home/user/media/TV Shows/" # User home directory
MEDIA_PATH_PREFIX = "/mnt/media/TV Shows/" # Mounted drive
MEDIA_PATH_PREFIX = "/opt/media/TV Shows/" # System directoryDocker Users:
# If running script on host but media is in container path:
MEDIA_PATH_PREFIX = "/host/path/to/TV Shows/"
# Match the actual host filesystem path, not the container pathImportant: The script converts Sonarr/Radarr's internal paths to your actual filesystem paths. If you're unsure, use the --verify-paths option to test your configuration.
Always start here! Before running in execution mode, verify your path settings:
python sonarr-shrink.py --verify-paths
python radarr-shrink.py --verify-pathsThis will test if the script can find your media files. If it shows "NO" for files that exist, adjust your MEDIA_PATH_PREFIX setting.
Run in dry-run mode to see what would be deleted without actually deleting anything:
python sonarr-shrink.py
python radarr-shrink.pyExpected Output:
Found 15 oversized episodes
DRY RUN - No files will be deleted
Would delete: Breaking Bad - S01E01
File: /media/TV Shows/Breaking Bad/Season 01/Breaking Bad - S01E01.mkv
Size: 8.54 GB
Quality: Bluray-1080p
When you're ready to delete files:
python sonarr-shrink.py --execute
python radarr-shrink.py --executeThe script will ask for confirmation before proceeding with deletions.
Understanding the process helps set proper expectations:
- Sonarr/Radarr will detect missing files during the next library scan
- Episodes/Movies will show as "Missing" in the UI
- You can trigger manual searches to find replacements
- New downloads will follow your current quality profile
- Files may not be re-downloadable if they're no longer available on your indexers
Important: This process assumes your indexers still have the content available. Rare, older, or region-specific content may not be re-downloadable.
- Change your quality settings in Sonarr/Radarr to prefer smaller file sizes
- Verify path configuration with the
--verify-pathsoption - Run the script in dry-run mode to preview which files will be removed
- Execute the script to delete oversized files
- Manually refresh your library in Sonarr/Radarr:
- Sonarr: Go to Series → [series name] → Refresh & Scan
- Radarr: Go to Movies → [movie name] → Refresh & Scan
- Trigger searches for missing content:
- Sonarr: Activity → Queue → Search All Missing
- Radarr: Movies → Missing → Search All Missing
- Monitor downloads and verify quality profiles are working as expected
Consider these factors when running the scripts:
- Network I/O: Each file requires API calls and file system checks
- Batch processing: Default 5 files per batch with 10-second delays
- Large libraries: Consider running overnight for 1000+ files
- System load: Monitor CPU/disk usage during execution
Recommended Settings for Large Libraries:
BATCH_SIZE = 3 # Smaller batches for heavily loaded systems
DELAY_SECONDS = 15 # Longer delays to reduce system stressFor Very Large Libraries (5000+ files):
BATCH_SIZE = 2 # More conservative processing
DELAY_SECONDS = 20 # Longer delays between batchesThe tool keeps detailed history files that track processed media:
- Sonarr:
sonarr-shrink-history.json - Radarr:
radarr-shrink-history.json
History File Contains:
- The date of the last run
- Total number of processed files
- Details about each processed file including:
- Series/movie name and episode information
- Original file size and path
- Date when file was processed
- Quality information
Benefits of History Tracking:
- Prevents reprocessing the same files in future runs
- Provides an audit trail of what was deleted
- Helps with troubleshooting and recovery
- Useful for understanding script behavior over time
If something goes wrong:
- Check the history file for deleted file details and timestamps
- Restore from backup if you created one beforehand
- Manually search for specific episodes/movies in Sonarr/Radarr
- Review indexer settings to ensure content is still available
- Check download client for any stuck or failed downloads
The history file helps with recovery by providing:
- Exact file paths that were deleted
- Timestamps of deletions
- Original file sizes and quality information
- Series/movie identification details
| Problem | Solution |
|---|---|
| "Failed to connect" | Verify URL format includes http:// or https:// |
| "Unauthorized" | Check API key is correct and has proper permissions |
| "Connection refused" | Ensure Sonarr/Radarr is running and accessible |
| Timeout errors | Check network connectivity and firewall settings |
| Problem | Solution |
|---|---|
| "File does not exist" | Run --verify-paths to test path conversion |
| All files show as non-existent | Check MEDIA_PATH_PREFIX setting matches your actual paths |
| Mixed results (some found, some not) | May indicate network share, permission, or mounting issues |
| Permission denied | Ensure script has read/write access to media folders |
| Problem | Solution |
|---|---|
| No oversized files reported | Check your size threshold - try lowering MAX_SIZE_GB |
| Files exist but not detected | Verify you have media that actually exceeds the threshold |
| Empty library response | Check file permissions and API connectivity |
| Version compatibility issues | Ensure you're using Sonarr/Radarr v3 (API v3) |
| Problem | Solution |
|---|---|
| Script stops mid-processing | Check available disk space and system resources |
| Slow performance | Reduce BATCH_SIZE or increase DELAY_SECONDS |
| Network timeouts | Increase delays between API calls |
| Memory issues | Process smaller batches or restart script periodically |
API Compatibility: These scripts use API v3 endpoints, which remain stable across application versions.
Custom Ports: Ensure your URL includes the correct port (default: Sonarr 8989, Radarr 7878).
Version Issues: If you encounter API errors, verify your application is running and accessible, regardless of version.
- Start with a higher threshold and gradually lower it to control impact
- Always run in dry-run mode first to preview changes
- Test with a small subset before processing large libraries
- Back up important or rare files before running in execution mode
- Monitor system resources during processing
- Run during off-peak hours for large libraries
- Check indexer availability for content you're planning to re-download
- Review quality profiles before deleting to ensure suitable replacements exist
- Keep history files as they provide valuable audit trails
You might want different size limits for different types of content. Consider running the script multiple times with different configurations:
# First run: Very large files (>15GB)
MAX_SIZE_GB = 15.0
# Second run: Large files (>8GB)
MAX_SIZE_GB = 8.0
# Third run: Medium files (>4GB)
MAX_SIZE_GB = 4.0The scripts process all oversized files they find. For more selective processing:
- Use higher size thresholds to target only the largest files
- Review the dry-run output carefully
- Consider manually deleting specific files instead of batch processing
If you encounter bugs or have suggestions for improvements:
- Check existing issues to see if the problem is already reported
- Provide detailed information about your setup and the issue
- Include relevant log output and configuration details
- Test with the latest version before reporting
MIT License - See LICENSE file for details.
- The Sonarr and Radarr development teams for their excellent APIs
- The media management community for feedback and testing
- Contributors who have helped improve these scripts