19

How to remove duplicate tracks from Banshee?

2

4 Answers 4

7

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?

1
  • 1
    I wasn't under the impression that this question was specifically referring to that bug. You can end up with duplicate tracks in your library even if you never run into that importing/rescanning bug, and I'm not sure of any way to automatically remove them now that the option is no longer available in the Mirage extension. Jan 28, 2011 at 18:00
3

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.

2

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()
2

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.

1
  • I had a similar problem and this fixed it perfectly for me. Thanks. Oct 17, 2016 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .