Library db still has old path after moving collection to a new location

I’ve moved my collection to a new machine.

On the old machine I stored my music on an external drive. On the new machine I’m storing it internally for faster access.

I’ve updated the config file accordingly. So the collection location has changed from…
/Volumes/ExternalDrive/Users/patrick/Music/beets/collection
…to…
/Users/patrick/Music/beets/collection
…and beet config confirms this.

However, if I beet ls with the $path in the format, every file in the collection is still showing its path as:

/Volumes/ExternalDrive/Users/patrick/Music/beets/collection/AnArtist/AnAlbum/etc…

So it seems the absolute path is hard-coded into the collection db and is not generated relative to the directory config setting.

What’s the best way then to update the library db so that all the entries are pointing to the new collection location?

Having read the docs again, I’m going to attempt operating on the SQLite db. I’m in the fortunate position that every item in my collection has the same base path, so it’s the same operation for every row. I will of course back up the db first.

I’m also dreaming up a “beet relocate” command…

1 Like

There’s a small section on the FAQ about pointing beets to a new directory. From your situation, it sounds like beet move isn’t an option - modifying the SQLite database is probably easiest provided you have a backup. There’s a discussion on issue #1598 which provides an example SQLite query to replace part of a path.

I recently did the same thing: upgraded my NAS, and changed my path prefix. Modifying the SQLite DB is by far the easiest and cleanest route IMHO. The query I used was very simple:

update items set path = replace(path, '/voldemort/', '/quark/');

Because I knew those path fragments do not appear for my files anywhere else than at the beginning of each path.

1 Like