Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How to remove duplicate tracks from Banshee?

share|improve this question
    
Also please see this thread: askubuntu.com/questions/4323/how-can-i-find-duplicate-songs –  belacqua Jan 28 '11 at 18:48
    
sooo if I have say 1,00 duplicate tracks I need to run this command 1,000 times? –  user43446 Jan 25 '12 at 0:53
add comment

5 Answers

up vote 6 down vote accepted

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?

share|improve this answer
    
ok, i try it first thanks –  ok comp Jan 13 '11 at 6:13
    
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. –  michaelms Jan 28 '11 at 18:00
add comment

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.

share|improve this answer
add comment

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()
share|improve this answer
add comment

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.

share|improve this answer
add comment

non technical answer. Remove all tracks and add them again as long as there isn't loads of duplicates in your music folder

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.