Finding Duplicate Movies or TVShow Episodes in your Library



Movies:  
 

Code:
SELECT
    m.c00,                      -- Movie name
    p.strPath,                  -- Path
    f.strFilename               -- File name
FROM movie m

JOIN movie m2                   -- Join on self to find duplicates
  ON m.c09 = m2.c09             -- Map on IMDB ID
AND m.idMovie != m2.idMovie    -- Only if not same entry

JOIN files f                    -- Join file information
  ON f.idFile = m.idFile

JOIN path p                     -- Join path information
  ON p.idPath = f.idPath;

TV Shows:
 

Code:
SELECT *
  FROM episode_view e

  JOIN episode_view e2                -- Join on self to find duplicates
    ON e.idShow = e2.idShow           -- tv show ID
   AND e.idSeason = e2.idSeason       -- season number
   AND e.c13 = e2.c13                 -- episode number
   AND e.idEpisode != e2.idEpisode    -- Only if not same entry

  JOIN files f                    -- Join file information
    ON f.idFile = e.idFile

  JOIN path p                     -- Join path information
    ON p.idPath = f.idPath;