<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kodi.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=EvanPurkhiser</id>
	<title>Official Kodi Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://kodi.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=EvanPurkhiser"/>
	<link rel="alternate" type="text/html" href="https://kodi.wiki/view/Special:Contributions/EvanPurkhiser"/>
	<updated>2026-06-04T20:33:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://kodi.wiki/index.php?title=HOW-TO:Update_SQL_databases_when_files_move&amp;diff=63192</id>
		<title>HOW-TO:Update SQL databases when files move</title>
		<link rel="alternate" type="text/html" href="https://kodi.wiki/index.php?title=HOW-TO:Update_SQL_databases_when_files_move&amp;diff=63192"/>
		<updated>2013-08-12T08:10:11Z</updated>

		<summary type="html">&lt;p&gt;EvanPurkhiser: Add aditional query for updating the video library: Change TV show paths&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cleanup}}&lt;br /&gt;
XBMC has functions to fully manage its database files. Some advanced operations can be performed by editing the database tables directly on your PC. &#039;&#039;Be forewarned that database tables are relational (inter-related) - do not change any entries unless you are sure of the implications!&#039;&#039; Make a backup first, and worst-case, you just have to delete the corrupt database file and rescan your music, videos, or programs from within XBMC.&lt;br /&gt;
&lt;br /&gt;
If you are using a shared mySQL Database on a NAS, please follow this guide instead:&lt;br /&gt;
* [[HOW-TO:Share libraries using MySQL/Update Paths In MySQL]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Required Software&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Two popular SQLite interfaces for Windows are:&lt;br /&gt;
* [http://www.singular.gr/sqlite/ SQLite3Explorer]&lt;br /&gt;
* [http://www.yunqa.de/delphi/sqlitespy/index.htm SQLite Spy]&lt;br /&gt;
&lt;br /&gt;
A capable but unmaintained SQLite client for OSX can be found here:&lt;br /&gt;
* [http://saxmike.com/MySoftware/MySoftware.asp?Menu=MYSOFTWARE Mike T&#039;s SQLite Database Administrator Tool]&lt;br /&gt;
&lt;br /&gt;
A client for Linux (works on other *nix as well):&lt;br /&gt;
* [http://sqliteman.com/ Sqliteman]&lt;br /&gt;
&lt;br /&gt;
== Assumptions ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s say you&#039;ve got all your music stored on shared folder from a PC or NAS (network attached storage), and you&#039;ve scanned it into the MyMusic75.db database. You then changed a drive location, a computer name, etc.:&lt;br /&gt;
&lt;br /&gt;
Copy UserData\Database\MyMusic75.db over to your PC, run SQLite3Explorer, and examine the tables. You&#039;ll see that the paths in the table name &#039;paths&#039;, in a field named strPath.&lt;br /&gt;
&lt;br /&gt;
original location: &#039;&#039;&#039;smb://my_nas/old_share/Music/Library/...rest of path/filenames&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
new location: &#039;&#039;&#039;smb://my_nas/new_share/Music/Library/...rest of path/filenames&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Understanding SQLite text replacement ==&lt;br /&gt;
Here are two alternative ways to update paths in your database; they&#039;re presented here for your consideration. You can just generally just follow the instructions in the sections below, however.&lt;br /&gt;
&lt;br /&gt;
====Using the REPLACE function:====&lt;br /&gt;
It&#039;s important to realize that REPLACE() will replace &#039;&#039;every&#039;&#039; occurrence of the search string, so it&#039;s recommended that you use include the beginning of the URI (like smb://...)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;UPDATE path SET strPath = REPLACE(strPath,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
====Alternately, using the SUBSTR function:====&lt;br /&gt;
If you want to have guaranteed control over which characters get replaced, you can use the SUBSTR() function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;UPDATE path SET strPath = SUBSTR(strPath,1,13) || &#039;new_share&#039; || SUBSTR(strPath,23);&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can see that the table named &#039;path&#039; was updated to change the values in the field named &#039;strPath&#039;:&lt;br /&gt;
   * we took the first 13 characters of the original string &amp;quot;smb://my_nas/&amp;quot;&lt;br /&gt;
   * appended the string &amp;quot;new_share&amp;quot;&lt;br /&gt;
   * appended the 20th-onwards part of the original string to the end: &amp;quot;/Music/Library/...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So, the SUBSTR function returns a substring from an original string, taking these parameters:&lt;br /&gt;
   * original string to operate on&lt;br /&gt;
   * position of first character to extract&lt;br /&gt;
   * total number of characters to extract&lt;br /&gt;
&lt;br /&gt;
And the LENGTH function determines the number of characters in the original string; you can see that in this example how many characters remain after discarding the first 16.&lt;br /&gt;
&lt;br /&gt;
== Updating your Music library ==&lt;br /&gt;
Open the latest [[XBMC_databases#The_Music_Library|MyMusic*.db]] file in your sqlite program, and run the following command (substituting your paths as appropriate):&lt;br /&gt;
   UPDATE path SET strPath = REPLACE(strPath,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&lt;br /&gt;
&lt;br /&gt;
== Updating your Video library ==&lt;br /&gt;
Open the latest [[XBMC_databases#The_Video_Library|MyVideo*.db]] file in your sqlite program, and run the following command (substituting your paths as appropriate):&lt;br /&gt;
   UPDATE path SET strPath = REPLACE(strPath,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&lt;br /&gt;
   UPDATE movie SET c22 = REPLACE(c22,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&lt;br /&gt;
   UPDATE episode SET c18 = REPLACE(c18,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&lt;br /&gt;
   UPDATE art SET url = REPLACE(url,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&lt;br /&gt;
   UPDATE tvshow SET c16 = REPLACE(c16,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&lt;br /&gt;
&lt;br /&gt;
Open the latest Textures*.db file in your sqlite program, and run the following command (substituting your paths as appropriate):&lt;br /&gt;
   UPDATE path SET url = REPLACE(url,&#039;smb://my_nas/old_share&#039;, &#039;smb://my_nas/new_share&#039;);&lt;br /&gt;
&lt;br /&gt;
== Updating sources.xml ==&lt;br /&gt;
Edit [[Userdata/sources.xml|sources.xml]] in a text editor and do a global search-and-replace for &#039;&#039;&#039;smb://my_nas/old_share&#039;&#039;&#039; to &#039;&#039;&#039;smb://my_nas/new_share&#039;&#039;&#039;&lt;br /&gt;
[[Category:How-to]]&lt;/div&gt;</summary>
		<author><name>EvanPurkhiser</name></author>
	</entry>
</feed>