40
So I am using the console in SQLite Utilities to try and remove a selection from a playlist. I think I have the query figured out, but when I change it from SELECT to DELETE I get an error "Attempt to write a read only database" I changed my foobar2000 root and the music file that is getting targeted to write compatible. I think I did it correct, but this is my first time working with SQLite.
Here is my query if that helps
WITH DuplicateTitles AS (
SELECT title, bitrate,
ROW_NUMBER() OVER (PARTITION BY title ORDER BY bitrate DESC) AS row_num
FROM playlist
WHERE playlist_name = 'TestPl'
),
MaxBitrateTracks AS (
SELECT title, bitrate
FROM DuplicateTitles
WHERE row_num = 1 -- These are the tracks with the max bitrate for each title
)
DELETE FROM playlist
WHERE playlist_name = 'TestPl'
AND title IN (SELECT title FROM MaxBitrateTracks)
AND bitrate != (SELECT MAX(bitrate) FROM MaxBitrateTracks WHERE title = playlist.title)
AND title IN (
SELECT title
FROM playlist
WHERE playlist_name = 'TestPl'
GROUP BY title
HAVING COUNT(*) > 1 -- Only select duplicate titles
);
I had ai help me write it. It seems to only be selecting the correct stuff - Duplicate titles with the lower bitrates out of the dupes. The main problem was if the highest bitrate was tied among the dupes. But I think it's working now, at the very least it's good enough.
I want to delete them from the selected playlist, hopefully this is the correct method. I DO NOT want to delete them from my library. PLEASE let me know if that is what I am trying to do.
I have absolutely no idea what I am doing and it took me about 25 minutes to find the console and help documentation for SQLite Utilities. Please let me know if I am doing something dumb thanks for any help.