Batch editing an SQLite db

Polytropon freebsd at edvax.de
Sat Feb 14 01:40:36 UTC 2015


On Fri, 13 Feb 2015 21:49:53 +0100, Rolf Nielsen wrote:
> I recently changed from one ROM to another on my Android phone. The
> old one and the new one use different mount points for the external SD
> card, and because of this the music playlists I've painstakingly
> created are utterly useless. The player refuses to even open them,
> because the files in them are non-existent. These are SQLite database
> files, and I've been able to open them with the SQLiteEditor app for
> Android, but I've not found an option to replace all occurances of a
> string with something else. I have eight playlists with some 500 songs
> each, so editing them manually would be tedious. Is there something in
> the ports tree that can do this? SQL isn't a language I speak
> fluently, so I'd need some pointers as well. Basically I need to
> substitute "sdcard1" for "extSdcard".

Do you have r/w access to the database file and a SQLite
installation you can use? Then you can use its replace()
function with an UPDATE command:

	UPDATE <tableneme> SET <entry> = replace(<entry>, 'sdcard1', 'extSdcard') WHERE <entry> LIKE '%sdcard1%';

Here <tablename> is the name of the table which contains
the playlist entries, and <entry> is the "column name"
under which playlist entriy paths are stored.

"Sadly", I don't have to mess with SQL regularly anymore.
So not tested. :-)


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list