[HowTo] Get a list of all your media files from the Plex DB

I lost a hard drive and wanted to get a list of all my lost media files so i wrote this query and would like to share it if somebody else is going to need it someday.

How to use:

  1. Open the Plex Database in a SQLite Browser (Google for DB Browser for SQLite)
  2. Open your Plex DB (Located in: Plex Media Server/Plug-in Support/Database)
  3. Go to tab “Run SQL”
  4. Paste this code and hit the “Play” button
SELECT library_sections.name AS Libary, metadata_series.title as Series, metadata_season.'index' AS Season, metadata_media.title AS Title FROM media_items
INNER JOIN metadata_items as metadata_media
ON media_items.metadata_item_id = metadata_media.id
LEFT JOIN metadata_items as metadata_season
ON metadata_media.parent_id = metadata_season.id
LEFT JOIN metadata_items as metadata_series
ON metadata_season.parent_id = metadata_series.id
INNER JOIN section_locations
ON media_items.section_location_id = section_locations.id
INNER JOIN library_sections
ON library_sections.id = section_locations.library_section_id

If you’re looking for a filtered list by media location (path where the media is stored) go to the table “section_locations” and enter the ids in the where clause of the following query.

SELECT library_sections.name AS Libary, metadata_series.title as Series, metadata_season.'index' AS Season, metadata_media.title AS Title FROM media_items
INNER JOIN metadata_items as metadata_media
ON media_items.metadata_item_id = metadata_media.id
LEFT JOIN metadata_items as metadata_season
ON metadata_media.parent_id = metadata_season.id
LEFT JOIN metadata_items as metadata_series
ON metadata_season.parent_id = metadata_series.id
INNER JOIN section_locations
ON media_items.section_location_id = section_locations.id
INNER JOIN library_sections
ON library_sections.id = section_locations.library_section_id
WHERE media_items.section_location_id IN(100,101,102)

This is hopefully going to safe you some time.

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.