Recently Added changed to File Create/Modified date

Hello,

I bookmarked several forum posts before the Forum updates, and one in particular I can access, but it is either missing the content I require for Windows or Plex updates have since removed the capability.

I want to update the PLEX database for the Recently Added to correspond to the Windows Date added or Date modified (added preferred). There was a post by users sfnetwork and losangeles that were able to perform this using SQLITE3 at the link below;

I also when I first found this was able to perform on my Windows machine. I am setting up a new PLEX system and would like to perform this task again. However the screenshot sfnetwork used is missing, and I am not able to get the commands losangeles provided to work on my system. I also cannot PM anyone, so I can’t inquire directly.

Additional info;
Windows 10
PLEX Version 0.9.14.6
Anything else, please let me know.

Thank you in advance.

Bump. Anyone know those 2-3 lines of code?

Hello, you can get the old forum links to work. Remove index.php/ from the url
Example:
https://forums.plex.tv/index.php/topic/44965-sort-by-file-date-instead-of-when-added-to-plex/
becomes

astrofisher; While I thank you for that info, the problem exists with the link I posted due to the image used in that discussion is no longer available and that contained the lines of code I needed.

I was able to figure it out for any of those who are interested in updating your plex database for Date Added based on the file’s creation date, not when it was loaded into your plex DB using a Windows (7-10) based system;

  1. Download SQLITE3.exe (http://www.sqlite.org/download.html)
  2. Place the .exe in your Plex Server database location; Typically: “C:\Users\NAME\AppData\Local\Plex Media Server\Plug-in Support\Databases”
  3. Run SQLITE3 as Admin
  4. type: “.open com.plexapp.plugins.library.db”
  5. type: “update metadata_items set added_at=(select media_items.updated_at from media_items where media_items.metadata_item_id=metadata_items.id);”
  6. type: “.quit”
  7. Close out of Plex Media Server (tray icon and all)
  8. Relaunch Plex Media Server
  9. Enjoy re-sorted titles
5 Likes

works perfect thanks alot!

Outstanding! Worked a treat. Thank you!

anyone knows how to do this on plex for shield?

@Olivier.75 said:
anyone knows how to do this on plex for shield?

It’s not possible. The Plex data folder on the shield is not accessible without “rooting” the device - and you don’t want that.

Thank you for figuring this out. Any chance anyone knows how to perform the steps above for Mac OS X ?

steps would be the same on Mac, just find SQLITE3 for Mac/Unix and do the same thing within your terminal. Or don’t use a Mac

I attempted to use the same commands on the Mac. I was able to get to the sqlite prompts and load the database but the command listed about did not seem to work. Does anyone else have some ideas on how to implement this on the Mac? Would rebuilding the database also accomplish the same thing?

Thank you… This worked perfectly.

Thank you so much MI95SHO! I just moved around my folders and everything went out of whack. This fixed the sort to how it looked before I started messing with the folders.

I cannot thank you enough!

Tried this on a mac and get:

Error: no such table: metadata_items

Any ideas?

Make sure you run the command on the “com.plexapp.plugins.library.db” file. The “metadata_items” table does exist in there.

Here’s a great open source application to view the SQL database in a more user friendly way: https://sqlitebrowser.org/

Just open the database file with the above application (be sure to close down Plex Media Server first) and click on the Execute SQL tab, then enter in:
update metadata_items set added_at=(select media_items.updated_at from media_items where media_items.metadata_item_id=metadata_items.id);
Now click the play button to run it. It should only take a moment and then you’re all done.

Just FYI, the path to the database file on Mac OS is:
“/Users/NAME/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db”

1 Like

I personally found that the recommended code above didn’t help my situation. After looking at the database, I noticed that the created_at field in the media_items table was in exactly the order I wanted. A small change to the command and my Recently Added looks perfect! Try this if the above code doesn’t work for you;

update metadata_items set added_at=(select media_items.created_at from media_items where media_items.metadata_item_id=metadata_items.id);

Hope this helps someone. I’m on Windows 10 btw.

1 Like

I thought I had this working, after upgrading to Version 1.14.0.5470 and re-running the commands as above, I’m still seeing some files “as recently” but WINDOWS shows otherwise (yes I did manipulate the data fields - created, modified, last accessed) with a 3rd party Windows plug in.

Exactly what I was looking for thanks, will give it a try in the next few days! :slight_smile:

THANK YOU so much for posting this!