I recently moved my media to a new, larger hard drive and found that it had reset all of my “date added” results to when I added the new path for my libraries. I found some guides to reset this to the “modified” date, and was able to make that work using SQL to edit the file “com.plexapp.plugins.library.db”, and it worked fine for all my movies and TV series. Where it didn’t help was with Episode- and Track-level “date added” info - those have remained the same.
Can someone help point me to where in the database file individual song and episode information is stored? I assume it’s a different part of the database, so I just need to tweak the code a little bit.
Here are the directions I followed that worked for movie level data:
Solved this with the help of the SQL subreddit to work out the right coding.
Copy the code below and run a SQL editor to run it on you database (back it up first). You may need to edit the media_type value to whatever your system uses for individual songs - find that by looking around metadata_items until you find a row with song-specific information.
WITH subq
AS (
SELECT song.id,
album.originally_available_at
FROM metadata_items AS song
INNER JOIN metadata_items AS album
ON song.parent_id = album.id
AND song.metadata_type = 10 --edit this to whatever your system uses for individual songs.
)
UPDATE metadata_items
SET added_at = subq.originally_available_at
FROM subq
WHERE metadata_items.id = subq.id AND subq.originally_available_at IS NOT NULL;