Page 1 of 1

Moving files to a new location

Posted: Wed May 14, 2008 1:01 pm
by Kessel
I want to move my music files to a new drive, but want to be able to keep the ratings I've assigned to them. The files are currently in the library by means of a watch folder.

If I move the files to a new location and add the new folder as a watch folder, I get duplicates in the library. Obviously deleting the original list from the library is not the solution because I would lose all the ratings I've assigned.

What are the steps I should take to do this without damaging my current setup?

Re: Moving files to a new location

Posted: Wed May 14, 2008 1:23 pm
by sbooth
Right now this is a shortcoming in Play, and you can't do it. I plan on adding this ability for the next release.

However, Play stores all the track information in an sqlite3 database. If you wanted to modify the database directly to point at the file's new locations it shouldn't be too hard, it would just require a little bit of SQL. If you're interested I can post some code to help.

Re: Moving files to a new location

Posted: Thu May 15, 2008 6:07 pm
by Kessel
That would be great. What do I need to do?

Re: Moving files to a new location

Posted: Thu May 15, 2008 10:09 pm
by sbooth
First you will need to download sqlite. You can compile from source, use MacPorts to install it, or just download the precompiled OS X binaries.

You will be editing the ~/Library/Application Support/Play/Library.sqlite3 file.

Start up sqlite using

Code: Select all

% sqlite ~/Library/Application\ Support/Play/Library.sqlite3
You may first want to check out the contents of the file:

Code: Select all

sqlite> select * from streams limit 10;
This will display 10 tracks from your library.

Here is some sample output:

Code: Select all

227|file://localhost/Users/xxx/Music/Sheryl%20Crow/The%20Very%20Best%20of%20Sheryl%20Crow/17%20First%20Cut%20Is%20The%20Deepest%20(Country%20Version).flac|-1|-1|232184246.579575|||||||First Cut Is The Deepest (Country Version)|The Very Best Of Sheryl Crow|Sheryl Crow|Sheryl Crow|Rock|Cat Stevens|2003||17|17|1|1||USAM10300536|0602498611548|||||||||FLAC|FLAC|FLAC|16|2|44100.0|9903480|
The part you will be replacing is the url field, which is displayed as the second block in the output, in the case above the URL is file://localhost/Users/xxx/Music/Sheryl%20Crow/The%20Very%20Best%20of%20Sheryl%20Crow/17%20First%20Cut%20Is%20The%20Deepest%20(Country%20Version).flac.

You'll need to know both the new path and the old path for the files, and be able to convert them to URL encoding. If you don't have any weird characters URL encoding will just replace spaces with %20.

Let's say you moved your files from /Users/xxx/Music to /External HD/Music. The original URL prefix would be file://localhost/Users/xxx/Music and the new URL prefix will be file://localhost/External%20HD/Music.

You can replace all instances of the old prefix with the new prefix using

Code: Select all

sqlite> update streams set url=replace(url, "file://localhost/Users/xxx/Music", "file://localhost/External%20HD/Music");
That should do it.

You definitely want to make a back up of your Library.sqlite3 file before you edit it in this way, just in case something weird happens. If you need help converting filesystem paths to URLs I can help with that also.

Re: Moving files to a new location

Posted: Sun Feb 08, 2009 2:09 pm
by g3power
In case you want to perform modifications offline in a text editor editing in sql syntax you can do it like this:

Using Terminal, cd to the folder where you want to dump your library. Then...

Code: Select all

sqlite3 ~/Library/Application\ Support/Play/Library.sqlite3 .dump > Library.sql
... modify Library.sql to your heart's content ...

Code: Select all

mv ~/Library/Application\ Support/Play/Library.sqlite3 ~/Library/Application\ Support/Play/Library.sqlite3.backup

Code: Select all

sqlite3 ~/Library/Application\ Support/Play/Library.sqlite3 < Library.sql
... done.