mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-23 23:20:51 +01:00
After moving folders for library, every item is duplicated, and one version not playable as file not existing in that path #6131
Labels
No labels
area:database
awaiting-feedback
backend
blocked
breaking change: web api
bug
build
ci
confirmed
discussion needed
dotnet future
downstream
duplicate
EFjellyfin.db
enhancement
feature
future
github-actions
good first issue
hdr
help wanted
invalid
investigation
librarydb
live-tv
lyrics
media playback
music
needs testing
nuget
performance
platform
pull-request
question
regression
release critical
requires-web
roadmap
security
security
stale
support
syncplay
ui & ux
upstream
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: starred/jellyfin#6131
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @OlJohnny on GitHub (Jul 17, 2024).
This issue respects the following points:
Description of the bug
What I did to arrive at the problem
previously i had all my series in a folder called
/media/Serien/Serien.at some point i moved some series from the original folder into
/media/Serien/Serien/_done/and enabled theAutomatically merge series that are spread across multiple folderssetting.after i saw, that jellyfin wasn't able to find series folders inside the
_donefolder, i moved all remaining series into/media/Serien/Serien/_not_final/.At that point I also changed the media path from the series library to both new paths.
Now the problem
Every episode for every show is now duplicated.

One episode shows the new path.

One episode shows the old non-existing path

And no matter what i do, i can't seem to get rid of the "invalid" items.
I have:
Reproduction steps
I wasn't able to find out under which circumstances exactly this issue happens.
It is a possibility, that in the description above, i changed a setting/path or moved some items around during a library scan, thus resulting in this weird side effect.
What is the current bug behavior?
Jellyfin is not able to detect that the underlying file to these duplicated episodes is not there anymore, even though it is impossible to play these episodes (results in a playback error obv.).
Afaik there is also no way to tell Jellyin to just delete every item to which the underlying file is not existing anymore.
What is the expected correct behavior?
The way plex handles this issue is quite nice:
When during a library scan it is detected that an underlying file for a library entry is not found anywhere anymore, the item gets marked as "Not found" with a trash can symbol.
If needed, one can run the "Delete not found items" tasks on the not found item or whole library upon which the/all not found items get deleted from the jellyfin DB.
Thus my main question:
Is it possible to run some kind of maintenence script or database function to manually delete all non-existing items?
Jellyfin Server version
10.9.7
Specify the build version
i cant see the build number in the dashboard
Environment
Jellyfin logs
@OlJohnny commented on GitHub (Jul 17, 2024):
one more addendum: the duplicated episodes are able to be seen on multiple different devices using multiple different platforms and apps/browsers
so if anybody know how it is possible to run some kind of maintenence script or database function to manually delete all non-existing items, please let me know!
@gnattu commented on GitHub (Jul 17, 2024):
You need to perform a full library validation by running this scheduled task, which should remove all the invalid entries.
@OlJohnny commented on GitHub (Jul 17, 2024):
Thanks for your suggestion!
I just now did that, but it sadly did not change anything :/
@cvium commented on GitHub (Jul 17, 2024):
How many libraries do you have?
@OlJohnny commented on GitHub (Jul 17, 2024):
I have 11 libraries, however they are non overlapping regarding the folder structure.
Also I waited until the library scan was complete before checking that the duplicated episodes still exist :)
@TooMuchMario commented on GitHub (Jul 17, 2024):
Hi! I just fixed a similar issue for myself, and I'd wanted to tell you if you may be experiencing the same thing I was.
Each of the shows had an .NFO file in the show's folder. Feeding Jellyfin with the incorrect metadata information. After deleting the .NFOs and replacing all metadata, Problem solved!
Hope this helps! Good luck!
@OlJohnny commented on GitHub (Jul 17, 2024):
Thanks for the suggestion!
In my case, i am not using any
.nfofiles, neither can jellyfin write to the media folders.However forcing the library to refresh all metadata might be worth a shot!
@OlJohnny commented on GitHub (Jul 17, 2024):
Welp, that sadly didn't change anything :/
@OlJohnny commented on GitHub (Jul 18, 2024):
The only way I have found to steer around this bug: Add a completely new library on the same folder paths.
@solidsnake1298 commented on GitHub (Jul 19, 2024):
Did you have the "Missing Episode Fetcher" metadata provider enabled in your library's settings? I believe this is a relatively new addition from the TVDB plugin.
@OlJohnny commented on GitHub (Jul 20, 2024):
No, I only have the default metadata providers enabled.
That includes TheMovieDb and The Open Movie Database
@alvitali commented on GitHub (Sep 4, 2024):
I'm experiencing this same issue on 10.9.9. Only happening to a few movies, some are now showing up as 3 different files, even though these folder paths do not exist anymore. Running the scheduled tasks and checking metadata didn't help; Jellyfin does not have write access to the libraries in question either.
I'm only seeing this issue in movie libraries (due to having moved the paths my movie files recently).
@alvitali commented on GitHub (Sep 7, 2024):
@OlJohnny Did you / do you have the 'Merge Versions' plugin installed by any chance?
I was able to solve this issue on my part by 'splitting all media files', after which the non-existent duplicates disappeared. Even though I had already uninstalled the plugin because of unrelated issues with its functionality, it somehow had "merged" the same file on different paths before. After noticing a "Split" option in the affected movies' menus I was able to reinstall the plugin to 'split' all the files and then uninstalled it again.
'Splitting' the files manually worked as well. Just fyi, in case this is what caused the issue for you too. In my case however, the issue only happened to some of the titles (about 5-10%) in the library I had moved though
@OlJohnny commented on GitHub (Sep 7, 2024):
@alvitali no i didn't have any extra plugins installed
@Kathard commented on GitHub (Sep 23, 2024):
@OlJohnny I found the problem. Tested on 10.9.11
I have been able to reproduce the exact bug.
The problem appears when you move from one folder to another, for example a series, and the source folder becomes empty.
Jellyfin doesn't update its metadata if the folder is empty.
[2024-09-24 00:15:57.876 +02:00] [WRN] [93] MediaBrowser.Controller.Entities.BaseItem: Library folder "X:\Novedades Series" is inaccessible or empty, skippingI move the serie "Grace" from:
X:\Novedades Series to X:\definitive\Novedades Series
if after moving the content, the source folder remains empty the content is duplicated in the metadata and the series appears duplicated.
Now, if I add a new series to the source folder, jellyfin cleans the metadata and the duplicated series is displayed correctly:
[2024-09-24 01:00:42.124 +02:00] [INF] [82] Emby.Server.Implementations.IO.LibraryMonitor: "Novedades Series" ("X:\Novedades Series") will be refreshed. [2024-09-24 01:00:42.128 +02:00] [INF] [28] Emby.Server.Implementations.Library.LibraryManager: Removing item, Type: "Series", Name: "Grace", Path: "X:\Novedades Series\Grace (2021)", Id: d0b80cd9-c58a-6714-dbac-3b4cf0995749 [2024-09-24 01:00:43.597 +02:00] [INF] [28] MediaBrowser.Providers.TV.SeriesMetadataService: Creating Season "Temporada desconocida" entry for "Adolfo Suarez, el presidente" [2024-09-24 01:00:43.609 +02:00] [INF] [28] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Starting "ffprobe" with args "-analyzeduration 200M -probesize 1G -i file:\"X:\Novedades Series\Adolfo Suarez, El Presidente (2010)\Adolfo Suarez, El Presidente (2010) 1X01 Primera Parte Web-Dl 1080P Dd+ 2.0 H264-Lmain Drlast.mkv\" -threads 0 -v warning -print_format json -show_streams -show_chapters -show_format"I hope I explain well, the problem is that jellyfin does not clean its metadata if a folder is empty.
The alternative solution is to update all metadata of the duplicate series using the replace all metadata option.
@OlJohnny commented on GitHub (Sep 24, 2024):
Wow @Kathard that sounds very promising, as to what exactly happened in my case!
Now the question is, what the cleanest way is to prevent this edge case from impacting other users in the future
@Kathard commented on GitHub (Sep 24, 2024):
Until this problem is fixed, never leave a library folder empty.
If I remember correctly, this bug has been around since 10.9.6 or even earlier.
Let's see if any developer can fix it, it's beyond my knowledge.
@gnattu commented on GitHub (Sep 24, 2024):
This design choice addresses user concerns about lost libraries due to NFS mount point failures. When encountering an empty library folder, we can't distinguish between a failed network share mount and an intentional empty folder, which is uncommon. Because a full library rescan will take some time so we just don't remove things and hope it is a network share failure.
@OlJohnny commented on GitHub (Sep 24, 2024):
That makes complete sense and this feature also saved my butt in at least one occaseion!
Also this, i think, is the main reason for the "trashed items" feature of plex. When media is missing an item is trashed, but still shown. Users can individually remove trashed items or empty the trash for a whole library.
I would argue, that there should be a manual way (as in a separate button) to circumvent this safety feature and say "yes i know what i am doing, please really remove this empty library folder".
A separate drop down point in the "Scan Library" modal would probably a good place for this.

@marius-luca-87 commented on GitHub (Sep 24, 2024):
It would be nice if we could opt out of this functionality with a per library config for cases where NFS mounts and similar are not used.
I wasted quite a bit of time with a library that had 3 folder on seprate hdds. When I removed a folder and hdd the refresh wouldn't remove the missing items forcing me to create dummy empty folders.
@Kathard commented on GitHub (Sep 24, 2024):
Seeing that it is not a bug, but the correct functioning.
The quickest way to remove duplicate content is to click on the 3 dots dropdown of the duplicate content and replace all the metadata, so the disk scan is minimal and removes the duplicate.
@marius-luca-87 commented on GitHub (Sep 24, 2024):
Indeed it can be considered that it's working as intended. But having to repeat this on dozens of entries isn't exactly user friendly. It would make more sense to either have a new scan method that removes missing entries or an opt out option for libraries.
(In my personal use cases where all the content is local having folders/files disappear implies that I have bigger issues that some lost metadata in Jellyfin)
@OlJohnny commented on GitHub (Sep 24, 2024):
To clarify what the actual issue/bug is after @Kathard and @gnattu great explanations:
The described mechanism is supposed to prevent a whole library of items being erroneously removed, if an existing library folder is suddenly empty (can realistically happen due to a multitude of reasons).
However the mechanism somehow also applies when manually removing an existing empty library folder.
In this case there is no built in way to mass remove these "ghost" duplicate items. "Replace all metadata" does not work. Probably the same mechanism applies here.
I personally think that the described mechanism should not apply to manually removing empty library folders and the "replace all metadata" button (at least when pressing manually, schedule maybe not).
I also don't think that an opt out setting in the library settings is the most appropriate option, as this issue probably only happens very rarely. Changing a setting for a one-time operation again opens users up to accidentally deleting library items after forgetting to change it back.
This is bad UX.
A one time button to delete the duplicate items would be way more appropriate.
@Kathard commented on GitHub (Sep 24, 2024):
@OlJohnny However the mechanism somehow also applies when manually removing an existing empty library folder.
In this case there is no built in way to mass remove these "ghost" duplicate items. "Replace all metadata" does not work. Probably the same mechanism applies here.
In this case...
If you delete an empty folder, I understand that you should also delete it from here and this would remove duplicate content:
(example of deleting a library folder)

I just tested it and it instantly removes duplicates.
@marius-luca-87 commented on GitHub (Sep 24, 2024):
For me removing the folder in the library and unmounting the hdd would lead to exception being thrown about the movie folder not existing. (entire path didn't exists as a "/opt" folder got removed). I was using the official docker image on a fedora machine and just decided on recreating the entire library.
@chaudharydeepanshu commented on GitHub (Oct 6, 2024):
How about this way:
Jellyfin could attempt to create a temporary file at the specified empty/inaccessible location. If the file creation succeeds, we can determine that the path exists but is empty. In that case, Jellyfin would remove the entry as it's empty. But, if the folder creation fails, we could ignore it.
This will help distinguish between an empty valid path and an unmounted/inaccessible one.
Please correct me if I'm misunderstanding the issue here.
@gnattu commented on GitHub (Oct 6, 2024):
A mount point can be a writeable empty directory when unmounted so we cannot check it this way.
@chaudharydeepanshu commented on GitHub (Oct 6, 2024):
Got it, thanks for the clarification.
Hmm, a new scan option seems like a good approach then. Something like "Full Refresh Based on Availability" would treat inaccessible paths as empty.
This could fit under the "Library -> Scan library -> Refresh mode" setting, allowing users to choose the refresh type.
@adiberk commented on GitHub (Oct 13, 2024):
Hitting same issue in windows Jellyfin 10.9.8. I migrated hard drives which I guess resulted in an issue. I have since learned how I can do a better job! What exactly is the temporary solution though? I can't find any .nfo files in my folders where I am seeing this issue.
Is there a way I can manually delete the metadata folder for the series since jellyfin isn't properly cleaning it?
@notmeta commented on GitHub (Oct 13, 2024):
Take a look at this discussion, it helped me with a similar problem where I had duplicates after remapping volumes: https://github.com/jellyfin/jellyfin/discussions/6924
I ran queries against the sqlite database to manually fix paths.
On Mon, Oct 14, 2024 at 00:19, Adi Berkowitz @.***(mailto:On Mon, Oct 14, 2024 at 00:19, Adi Berkowitz < wrote:
@chaudharydeepanshu commented on GitHub (Oct 14, 2024):
@adiberk
The solution that worked for me was to recreate the library folder structure at the old location. Then, I added a simple text file in each of those folders. After that, I ran a library scan in Jellyfin. This allowed Jellyfin to recognize and properly remove the series and movies from that location.
Like:
@adiberk commented on GitHub (Dec 24, 2024):
Hello! Coming back here with a new question! I was able to resolve last issue by completely redoing Jellyfin lol, however I learned my lesson:)
I have a new question that is related.
How would I go about moving my movies folder to a new hard drive.
Ie here is original structure
G:/tv_shows
G:/movies
To
G:/tv_shows
H:/movies
I am using windows!
@FizzyMUC commented on GitHub (Jan 19, 2025):
Did you ever manage to remove the duplicates? I'm in the exact same situation right now :D
EDIT: I did fix it in my setup. I just stopped the container and re-mounted the old folder / unmounted the new folder (the old one was gone already, but I quickly added the old structure again and placed said empty txt-file in each folder), did one full library scan, stopped the container, mounted the new folder, started the container and all was good.
@alimbada commented on GitHub (Feb 10, 2025):
Running the
Merge Versionsscheduled tasks (Dashboard -> Scheduled Tasks) fixed duplicate episodes for me after I moved to a new NAS with a different file structure. Took me a a whole lot of figuratively banging my head against a wall before I accidentally discovered the fix by just hitting all the buttons. Hope this saves someone else a lot of headache.I still have some series which don't have duplicates but some or all of the episodes are still set to the paths from the old NAS and no amount of refreshing metadata will fix it. 🤦🏽♂️
@m00nwtchr commented on GitHub (Mar 25, 2025):
I have the problem that after removing a mount point in docker and changing the library paths in Jellyfin, it refuses to update the paths of existing media. I guess this must be the same "nfs mount detection" mechanism, but in this case it absolutely doesn't make sense.
@alimbada commented on GitHub (Mar 26, 2025):
You're better off removing your libraries and setting them up again. That's what I ended up doing. Jellyfin media scanning/metadata refresh is completely broken once you've set up a library.
@isZYKerman commented on GitHub (May 14, 2025):
Are there any solutions now? I encountered the issue today while migrating the videos on my server. I tried the merge plugin, but it just merged the invalid item with the valid item and made the situation worse. I do not want to rebuild the library because the watching history of my family will be destroyed and it will be a total mess. I cannot even delete the invalid item one by one for jellyfin will prompt me that it "cannot properly delete the item". That's really frustrating. So, are there any possible solutions now?
@fubar-coder commented on GitHub (May 15, 2025):
It would be nice if there would be a manual rescan which would remove all episodes and re-add them all.
@alvitali commented on GitHub (May 19, 2025):
I assume that this problem here is also related to the way Jellyfin handles empty path mappings: https://forum.jellyfin.org/t-jellyfin-indexing-library-paths-that-are-not-mapped-anymore
After removing all path mappings of a given library, the titles are still indexed in the Jf library, and play back just fine if the original files are still there. In order to actually remove the items of the library, I had to re-add an empty directory path to run a new scan
@developerwill commented on GitHub (Jun 11, 2025):
Hi @alimbada @cvium @fubar-coder @marius-luca-87 @gnattu.
I've just created this new API Endpoint: PATCH /force-new-library-paths/?name={libraryName}
This endpoint ensures a Jellyfin library curretly points to the paths, avoiding duplicates.
How it works:
✅ If the library doesn't exist, it creates it with the provided paths.
✅ If the library already exists, it deletes and recreates it with the new paths.
Usage:
// Request body
Note: You may need to manually refresh the library afterward to update primary image, otherwise Jellyfin will eventually take care of that.
🔗 GitHub: developed-by-will/jellydash
@Hexonator commented on GitHub (Sep 12, 2025):
Issue is still present. I migrated my metadata for a win reinstall and ended up having two of every episode since I changed the drive the files were on. Is the only resolution to "replace all metadata"?
@JPVenson commented on GitHub (Sep 17, 2025):
the 10.11-RC6 should no longer have that issue as data is now properly cleaned up. When releases please check.
@hjpaul7 commented on GitHub (Nov 9, 2025):
Still an issue on 10.11.2. After moving folders for library, I removed all old folders from Jellyfin library, added new one, rescanned. Docker up/down. Rescanned. They even show up after completely removing the library and rescanning.
Incorrect:
Correct
View:
@vgit5989 commented on GitHub (Nov 11, 2025):
I am on the latest version, had 1 movie and 2 tv shows that were used for testing my environment. I deleted the media files from my storage and expected to have the option to delete it from jellyfin (initially assumed it would auto delete) but even on the latest version I still see remnants of the shows/movie. Ideally I would like to remove delete media objects completely including the metadata. It can be locked behind the admin interface, but having the option would be nice.
@war3zlod3r commented on GitHub (Nov 21, 2025):
I'm also currently experiencing this issue on 10.11.3 on Shows libraries, my Movies libraries seemed to clear and reindex correctly.
@FoZo commented on GitHub (Nov 25, 2025):
In my case, in order to resolve the issue I ended up deleting everything inside the config/metadata/library/* folder and then I ran Scan Library -> Replace All metadata -> Ticks on everything for every library.
Something gets corrupted when moving media between different folders/libraries.
@war3zlod3r commented on GitHub (Nov 25, 2025):
This didn't work for me only deleting and recreating the library worked.
@Cobraeti commented on GitHub (Dec 10, 2025):
Hi, in case it could help, here are my notes on how I can now achieve a full TV show move (from main storage to archiving storage in my case) with no remaining duplicates.
I'm now running Jellyfin server version 10.11.2 (Linuxserver.io Docker image), but I will also leave the steps I had to go though when I was still running 10.10.7 a few weeks ago.
First, here are the settings I put in place (full-time, but it's personal tastes, especially concerning live/scheduled stuff that I decided to live without):
Then I proceed with the following steps for each TV show to archive:
⚠️ The informations above are what I feel easier to manage, all settings/steps are maybe not required/recommended ⚠️
I'm really sad there is no cleaner and user-friendly way (or I didn't find out) to go through this process as it is on Sonarr (it even offers to manage the migration itself 😍), but the above steps are the least painful to me.
I had a look to Jellyfin-Migrator (which is a really great project by the way and really deeply documented), but I had to give up for now, as extracting only the interesting part to manage a "simple" local folder move was out of my coding and thinking skills... 😅