Moving files to a new location

Get help on playing your audio with Play.
Post Reply
Kessel
Posts: 3
Joined: Wed May 14, 2008 12:58 pm

Moving files to a new location

Post by Kessel » Wed May 14, 2008 1:01 pm

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?

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: Moving files to a new location

Post by sbooth » Wed May 14, 2008 1:23 pm

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.

Kessel
Posts: 3
Joined: Wed May 14, 2008 12:58 pm

Re: Moving files to a new location

Post by Kessel » Thu May 15, 2008 6:07 pm

That would be great. What do I need to do?

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: Moving files to a new location

Post by sbooth » Thu May 15, 2008 10:09 pm

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.

g3power
Posts: 1
Joined: Sun Feb 08, 2009 2:01 pm

Re: Moving files to a new location

Post by g3power » Sun Feb 08, 2009 2:09 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests