Note: This is a simple ‘Week-end adventure’, to make a tedious task into automated, fast and reliable one. The output may not be completely bug free.
Problem Description:
I have ‘a lot’ of songs in my media library and I use SongBird player to listen to them. There are some ‘Not so good’ songs in the library too, which I never like to listen and dont want SongBird to repeat it ever in future. I wanted to pick all such songs and delete them from my library (from the file system actually) so no media player can play them again!
Options:
So, last option from list above, seemed the best. But missing part was “Periodically delete all songs with rating 1”, how to do that!. I searched in SongBird help and closest I could find was,
Imagine 52 songs with rating 1 are to be processed, above procedure would take at least 6 minutes, and make me so bored that I will need a coffee. That was the birth of my wish to create a small utility / script that goes through the songbird library and deletes all rating 1 songs. So, I started the research…
So, here came another set of choices. Where to write this code so that it is fast, flexible (change can be done without much hassle), simple. I had few choices.
After a few minutes of thoughts, I chose Batch script to be the way to go. The task was though, if it’d been .NET I could have found some client library to access database. I had to find something similar for command line or write a small tool that does SQLite part and returns the output! Here’s how the research went.
Code for Batch Script:
@echo off REM Generate Songs.csv file sqlite3 "C:\Users\Jigar Mehta\appdata\Roaming\Songbird2\Profiles\dv86zu0s.default\db\main@library.songbirdnest.com.db" "select media_item_id, content_url from media_items" > songs.csv REM Convert URL style path to file system path ssr 0 "file:///" "" Songs.csv ssr 0 "/" "\\" Songs.csv ssr 0 "%%20" " " Songs.csv ssr 0 "|" "," Songs.csv REM Query Songbird database for All Songs with Rating = 1, and write path to all such files to a temporary file sqlite3 "C:\Users\Jigar Mehta\appdata\Roaming\Songbird2\Profiles\dv86zu0s.default\db\main@library.songbirdnest.com.db" "select * from resource_properties where obj like '1' AND obj_searchable like '1'" | findstr "|28|" > tobeDeleted.txt if exist tobedeleted.txt ( for /F "delims=|" %%i in (tobeDeleted.txt) do ( type songs.csv | findstr "^%%i," > deleteList.txt ) ) REM Actually DELETE the file from the disk. if exist deletelist.txt ( for /F "tokens=2 delims=," %%j in (deleteList.txt) do ( echo Deleting : %%j del "%%j" ) ) REM Remove temporary files created during the process. if exist deletelist.txt del /Q deleteList.txt > nul 2>&1 if exist tobeDeleted.txt del /Q tobeDeleted.txt > nul 2>&1 if exist songs.csv del /Q songs.csv > nul 2>&1
I have uploaded all the files (Batch script + Other tools like sqlite3.exe and ssr.exe used by batch script). Please download them from here.
If you want to use the script, please make sure you change path to your database file in the batch script. HTH,
Stay tuned..
PingBack from http://microsoft-sharepoint.simplynetdev.com/removing-songs-from-disk-with-rating-1-in-songbird/
Hi and thanks for this great script!
Sorry for my badly english!
Your article is some month old but this is
what I searched for (already give 1 star
for the songs not so good - in my opinion).
But:
It does'nt work right:
1.The 28 isn't ever the right number!
You can get it with
select property_id
from properties
where property_name like '%#rating%'
2.Only the last file will be deleted
Don't use >, use >> to add lines to a file (> writes the file new):
...findstr "^%%i," >> deleteList.txt...
Greatings from Germany!
Sven
Hi,
I just published an extension to do exactly this (your option #3 :)), delete a file from disk from within Songbird. Check it out if you are interested: www.thebitguru.com/.../350-New%20Songbird%20Extension:%20Delete%20from%20Disk
Official download: addons.songbirdnest.com/.../1942