Pain & Suffering. Cleanup Jellyfin Libraries
Description and use
In Jellyfin, deleting folders from the filesystem leaves dangling references that break library scans. A Bash script stops the service, finds and deletes the corresponding SQLite entries, then rescans the library successfully.
Problem
Jellyfin ignores filesystem deletions, leaving dangling references that break library scans and prevent new files from being recognized.
Outcome
Dangling references are removed and the library rescans without errors, restoring normal media discovery.
Workflow
- Delete the folder from the Jellyfin UI if present
- Stop the Jellyfin service via Dashboard or systemctl
- Locate and backup the Jellyfin SQLite database (e.g., /var/lib/jellyfin/data/jellyfin.db)
- Install sqlite3 if missing
- Search the BaseItems table for items matching the deleted folder name
- Delete those items and their children from the database
- Start Jellyfin
- Run a library rescan for the affected folder and verify no errors
Evidence
Jellyfin still has the references to those files, but they are absent in the filesystem. This breaks the library scanning and Jellyfin won't be able to recognize new files when you add them.
Here's a bash script to automate the deletion step
- Record date: 2026-09-06T15:36:45.653Z