How to remove duplicate tracks from Banshee?
Solution 1:
It is a known bug that has been fixed in the newer versions of Banshee.
You can use the latest version of Banshee from the Banshee PPA:
sudo add-apt-repository ppa:banshee-team/ppa
sudo apt-get update && sudo apt-get upgrade
How do I subscribe to a bug?
Solution 2:
Locate the sqlite3 database (~/.config/banshee-1/banshee.db) and run the following query:
delete from coretracks where TrackID in
(
select trackid from
(
select TrackID as trackid, count(TrackID) as c from coretracks
group by TitleLowered,ArtistID,AlbumID,Title
)
where c > 1
);
PS Use the command "sqlite3" to open the database, and not just "sqlite".
PPS I had to run the query several times, each run only deletes one additional duplicate. This happens because the inner select only gives you back the ID of one surplus track for each Title/Artist/Album combination.
Solution 3:
This answer uses python to access the banshee database, then perform the sql action which donbicca lists with a twist. Instead of having to run the sql code many times, I have asked python to loop the sql code over the number of instances which exist in the sql code. You only need to run this code once. You need to replace your home path (replace "/home/JONDOE" with your home path).
#!/usr/bin/env python
import sqlite3
#open database to determine number of rows to loop over
db = sqlite3.connect('/home/me/.config/banshee-1/banshee.db')
cursor = db.cursor()
a = cursor.execute('SELECT TrackID from coretracks group by TitleLowered,ArtistID,AlbumID,Title')
a_trackid = a.fetchall()
db.close()
#Close database to ensure results do not impact future results. Then reopen database
db = sqlite3.connect('/home/me/.config/banshee-1/banshee.db')
cursor = db.cursor()
sql = ('DELETE from coretracks where TrackID in (SELECT TrackID from (SELECT TrackID as trackid, count(TrackID) as g from coretracks group by TitleLowered,ArtistID,AlbumID,Title) where g > 1)')
for i in a_trackid:
cursor.execute(sql)
db.commit()
db.close()
Solution 4:
Other alternative to remove duplicqtes song from banshee sqlite database:
cd /home/youruser/.config/banshee-1/
Close Banshee FIRST! Backup your DB:
cp banshee.db banshee.db.bck
In case you don't have sqlite installed:
sudo apt-get install sqlite3
Open DB:
sqlite3 banshee.db
Type this query:
DELETE FROM coretracks WHERE TrackID NOT IN (SELECT MIN(TrackID) FROM coretracks GROUP BY TitleLowered, ArtistID,AlbumID,Title);
exit:
.q
You're done, open Banshee and check the result.