Movie file scan order is reversed

Server Version#: 1.42.2.10156
Player Version#: 4.157.0

For some reason my Plex server decided to rebuild/rescan half of my movie library. (why?, would be a different topic). When it was scanning all those files, I notice that it rebuilds it in the reverse order, that is it scanned the new timestamped files/directories first and the latest scanned file had the oldest time-stamp. This is the order it added the movies to the libraries (newest timestamp directory first, oldest timestamp directory last).

This scan order makes it so that on the Home page, the “Recently Added Movies” show the oldest movies rather than the newest ones, and when sorting the movie library “By Date Added” it would show the oldest a the top.

Is there a way to fix that problem? if this is a core to the file scanner, can you change it to scan oldest first? It will not help me (unless I rebuild the library), but it will help others

I suppose the key question will indeed be, why your library was reset in the first place.
Plex won’t follow a specific order when scanning your files. Unless it’s an all-new library, Plex will treat items as newly added based on the date they’re (re-) added to Plex – during the very initial setup, Plex might consider the file date instead.

As for the “why”…
the most common scenario why Plex might consider it has to do a full reset is a combination of Settings > [Server Name] > Library > Empty trash automatically after every scan being enabled and an external/network drive that takes too long to spin up. If a drive isn’t available at all during a periodic scan, Plex will ignore it – but if it comes “alive” after Plex already marked some of the files as missing, that can result in those “temporarily missing” files to be removed. When they’re added back during a subsequent scan, Plex considers them to be new items.
So… if your drive / setup could have that issue, you should disable Empty trash automatically after every scan. That way, Plex will always keep the library record and reconcile it once an item is found again.

Thank you very much,

As to why it happen? The external drive was hanging and not responding while plex just stated scanning the drive. I killed plex server process as I was trying to eject the external drive, but it didn’t help. Then I physically unplugged the drive and restarted the Plex server. I assume what you describe is exactly what happen because it only removed about half of the movies.
When restored, it did restore correctly the watched/unwatched check mark, even though they were considered “new” movies.

I’m less worried about what happen, as it was a single time in the past 5 years. I will follow your recommendation and disable the “empty trash…”

However, you say that it doesn’t scan in specific order, but the scan order was exactly in reverse to the timestamp of the directories, maybe it’s coincidental, but it should really scan in order from oldest to newest, to keep the “Recently added” correct. make sense?

btw: what order does it follow when it’s a all-new library?

Unless you’ve disabled it, Plex Media Server creates backups of your database every 3 days and keeps the latest 3 (or maybe it’s 4?). So, to get back to where you where, you could try following the guidance in this article to restore a previous backup (the most recent before the incident):

https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/

It is added in descending order of the media files’ modified timestamps. That is, the most recently-modified files will be shown as the most recently-added media.

Thank you.

I did restore following your recommendation. Works great!!!

So It is added in descending order of the media files’ modified timestamps only for all-new library, but not for an already existing library when scanning? it should, shouldn’t it?