Hello,
This is a follow-up to a previous post that I opened here : Need Help With SQL Query : Plex SQLite.exe
With much help from @DTR last year I have 2x SQL scripts that help me find duplicate entries in plex. I am running these once a week but I am starting to encounter larger and larger numbers of false-positives due to my use of files with CD1 and CD2 in the filename.
Can someone help me to add this one exception, I keep getting syntax errors. I need something like:
WHERE strfilename NOT LIKE ‘%CD1%’ and strfilename NOT LIKE ‘%CD2%’
But I am getting syntax errors trying to add this to:
.header on
.mode csv
.output //MyServer/MyShare/Misc/Scripts/DuplicateMovies/PLEX/SQL_DUPES_PLEX_RESULTS.csv
SELECT metadata.title AS Title, parts.file AS Path FROM media_parts parts
INNER JOIN media_items items ON items.id=parts.media_item_id
INNER JOIN metadata_items metadata ON metadata.id=items.metadata_item_id
INNER JOIN (
SELECT guid FROM metadata_items
WHERE metadata_type=1
GROUP BY guid
HAVING COUNT(*) > 1
) duplicates ON duplicates.guid=metadata.guid
ORDER BY title, metadata.guid;
.header off
SELECT metadata.title AS Title, parts.file AS Path FROM media_parts parts
INNER JOIN media_items items ON items.id=parts.media_item_id
INNER JOIN metadata_items metadata ON metadata.id=items.metadata_item_id
INNER JOIN (
SELECT metadata_item_id FROM media_items
GROUP BY metadata_item_id
HAVING COUNT(*) > 1
) duplicates ON duplicates.metadata_item_id=metadata.id
WHERE metadata.metadata_type=1
ORDER BY title, metadata.guid;
.exit
I am sure that I am missing something obvious and trying to exclude the specific filenames in the wrong part of the SQL. I would appreciate any help.
~TJ