Skip to content

Instantly share code, notes, and snippets.

@FMCorz
Last active March 14, 2026 12:59
Show Gist options
  • Select an option

  • Save FMCorz/a298298c1be9742a219a462779d2b058 to your computer and use it in GitHub Desktop.

Select an option

Save FMCorz/a298298c1be9742a219a462779d2b058 to your computer and use it in GitHub Desktop.
Find duplicate movies in Kodi
-- Find the file ~/.kodi/userdata/MyVideosXX.db
-- Open with sqlite3
-- Run the following statement:
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;
@Heli-Guy
Copy link

Heli-Guy commented Oct 22, 2017

I tried this but got Error: no such table: movie
Any suggestions on what I'm doing wrong?

screen shot 2017-10-22 at 11 21 19 am

@Heli-Guy
Copy link

Heli-Guy commented Oct 22, 2017

Found the problem, copy pasted the path and typed it within "quotes", instead of using the space escape sequence for spaces '\ '

screen shot 2017-10-22 at 11 33 42 am copy

@fonic
Copy link

fonic commented Mar 14, 2026

As of 03/2026, database contents seem to have changed slightly: field m.c09 now stores some sort of unique ID which does not seem to be of much use when trying to identify duplicates (see https://kodi.wiki/view/Databases/MyVideos#movie).

However, relying on the movie name/title instead worked for me:

-- Find file ~/.kodi/userdata/MyVideosXXX.db
-- Open it with sqlite3
-- Run the following statement:

SELECT
    m.c00,                      -- Movie name/title
    p.strPath,                  -- Source path
    f.strFilename               -- File name
FROM movie m

JOIN movie m2                   -- Join on self to find duplicates
  ON m.c00 = m2.c00             -- Map on movie name/title
 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

ORDER BY m.c00;                 -- Order results by movie name/title

Save the SQL statement above to file find-duplicates.sql and then run:
sqlite3 --readonly ~/.kodi/userdata/MyVideosXXX.db < find-duplicates.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment