If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

[HowTo] Plex database modification - Moving media the right/wrong way

jelwelljelwell Posts: 38Members, Plex Pass Plex Pass

People ask all the time about moving media content. I think the reason they ask is because I think this article is misleading:
https://support.plex.tv/hc/en-us/articles/201154537-Move-Media-Content-to-a-New-Location

You can't move content to a new location and expect any of your manual changes to apply to the moved content. If your files are all named perfectly, then sure, Plex will simply rematch your files. But any content you added posters to, edited titles or tags, or did a "fix incorrect match" on won't be matched correctly no matter how closely you follow the above article. Please correct me if I'm wrong, but I have tried following the article multiple times and everytime I've reverted to my backup because my manual changes haven't been noticed.

What I want to do is (backup, then) open up the sqlite database and modify the location in the database itself. I'll report back how well this fails. :)

Joseph Elwell.

Best Answer

«1

Answers

  • PlexhilaratedPlexhilarated Plexperimentalist Posts: 1,620Members, Plex Pass Plex Pass
    edited December 2015

    I have moved media before... a couple of times... from a laptop to a server, then on the server from a location on one drive to a location on another drive within the same server.

    What I have found is that the KEY to a successful "move" is not to "move" the content at all, but instead "copy" the files to the new location, Plex will update automatically when the new location is assigned to the library, then once Plex identifies "both" copies of the media (you should see a blue "2" in every entry that was copied), it will be able to keep the association with the previous files metadata, then you can remove the location listed in the library and the move should be complete.

    I know others have tried this and had mixed results, but it has worked for me.

    Anxious to hear your results.

    My Current Plexistence:
    Server: Intel i5, 14x3TB Internal Drives, Win-10, running PMS, PlexPy, PlexWeb, PHT, PMP, Plex for Windows 
    27" Samsung Monitor and Vivitek HD/3D Projector, 10' Diagonal Fixed Screen
    Dell Laptop: Win-10, running PlexWeb, PHT, PMP, and Plex for Windows
    Samsung 55" LED TV: Samsung Plex App
    Vizio 50" UHD TV: Vizio Plex App
    Samsung 40" LED TV: Samsung Plex App
    Tablet PC: Windows 8.1 Mobile App
    Motorola Droid: Android App
  • jelwelljelwell Posts: 38Members, Plex Pass Plex Pass

    Looks like the following tables have references to filepaths that are pertinent here:
    section_locations - this has the "root" path for a given set of movies.
    metadata_items - this looks like all the MANUAL changes I made. So any movie that I manually updated has a reference there.
    media_streams - this has paths to my subtitle files.
    media_parts - looks like any movie that is split into 2 or more files has an entry here with a full file path. And some random movies that don't have multiple parts, not sure about this one.

    Joseph Elwell.

  • MovieFan.PlexMovieFan.Plex Posts: 15,887Members, Plex Pass, Plex Ninja Plex Employee
    edited December 2015

    @jelwell said:
    People ask all the time about moving media content. I think the reason they ask is because I think this article is misleading:
    https://support.plex.tv/hc/en-us/articles/201154537-Move-Media-Content-to-a-New-Location

    Not sure what is misleading. If you follow those steps, it works.

    You can't move content to a new location and expect any of your manual changes to apply to the moved content. If your files are all named perfectly, then sure, Plex will simply rematch your files.

    The whole idea is you want Plex to match your files so your files should be named properly in the first place. If your files are not named according to the way Plex wants and didn't get matched properly the first time, it obviously will not match it properly a second time.

    But any content you added posters to, edited titles or tags, or did a "fix incorrect match" on won't be matched correctly no matter how closely you follow the above article. Please correct me if I'm wrong, but I have tried following the article multiple times and everytime I've reverted to my backup because my manual changes haven't been noticed.

    Can you give an exact example of a movie, including filename and full before and after paths?

    What I want to do is (backup, then) open up the sqlite database and modify the location in the database itself. I'll report back how well this fails. :)

    I've actually looked into doing this too.

  • PlexhilaratedPlexhilarated Plexperimentalist Posts: 1,620Members, Plex Pass Plex Pass
    edited December 2015

    @jelwell said:
    Looks like the following tables have references to filepaths that are pertinent here:

    You should collaborate with @MovieFan.Plex, he's been working the Plex Database for quite a while.
    I always get a little nervous when third-party apps start changing things in my Database.
    No sense re-inventing the wheel.

    Just my $.02

    My Current Plexistence:
    Server: Intel i5, 14x3TB Internal Drives, Win-10, running PMS, PlexPy, PlexWeb, PHT, PMP, Plex for Windows 
    27" Samsung Monitor and Vivitek HD/3D Projector, 10' Diagonal Fixed Screen
    Dell Laptop: Win-10, running PlexWeb, PHT, PMP, and Plex for Windows
    Samsung 55" LED TV: Samsung Plex App
    Vizio 50" UHD TV: Vizio Plex App
    Samsung 40" LED TV: Samsung Plex App
    Tablet PC: Windows 8.1 Mobile App
    Motorola Droid: Android App
  • cayarscayars Posts: 4,059Members, Plex Pass, Plex Ninja Plex Ninja

    You can move you data and be successful. The key is to leave all DB pointers intact and let the scanner pick up the new location. It will then have 2 locations for each file.

    By this I mean to modify the storage locations for your current library and ADD the new location while leaving the old location.

    Do a complete refresh of your library. If you check any file it will have 2 locations listed. Now edit the library and remove the original location and do another refresh. Then delete "Empty Trash" and "Clean Bundles".

    Everything will be as normal if done correctly and only the new locations will show up/be used.

    Carlo

    10K+ Movies, 400 Shows - 33K+ TV Episodes, 380 Christmas Movies, 405 Documentary, 290 3D Movies, 1300 NFL Games, 1280 Educational Videos, Premium Music: 215K+ Tracks, 720 GB Plex Meta-Data.
    Thread on my setup with some tips and tricks: https://forums.plex.tv/discussion/131308/cayars-setup-walk-through-and-some-tips-and-tricks/p1
  • jelwelljelwell Posts: 38Members, Plex Pass Plex Pass

    Thanks to everyone posting for trying to help me.

    Plexhilarated : Awesome tip on checking out MovieFan.Plex's Database Tool. I suspect when I'm done I can contribute to that tool to help everyone else with this problem.

    @MovieFan.Plex said:

    @jelwell said:
    People ask all the time about moving media content. I think the reason they ask is because I think this article is misleading:
    https://support.plex.tv/hc/en-us/articles/201154537-Move-Media-Content-to-a-New-Location

    Not sure what is misleading. If you follow those steps, it works.

    As I pointed out before (and in more detail below) manual edits are lost. The opinion is whether "works" includes lost manual edits or not. If your definition includes losing that data, then sure, it works good enough. Good enough is clearly not good enough for me.

    @MovieFan.Plex said:
    You can't move content to a new location and expect any of your manual changes to apply to the moved content. If your files are all named perfectly, then sure, Plex will simply rematch your files.

    I can expect it to work. I know my expectations don't match Plex's abilities - which is why I am fixing it myself. And I'm hoping to contribute a better overall solution for others.

    @MovieFan.Plex said:
    The whole idea is you want Plex to match your files so your files should be named properly in the first place. If your files are not named according to the way Plex wants and didn't get matched properly the first time, it obviously will not match it properly a second time.

    I think it's not too much to ask for Plex to FIX my filenames for me when I manually match or edit my library using the Plex web interface. So that a rescan WILL match correctly. It would be great if there was a way to tell Plex to rename my files the best way possible. I have seen some third party tools that will attempt to do this for you, but the third party tools only work well for filenames Plex was likely to already match just fine. I also don't think it's too much to ask to offer a true move feature rather than shoehorning people into rematching everything. I'm running the rematch now (so that I can attempt to give specific examples) and it's taking hours. This is a huge waste of resources - plex already knows what all these files are. Moving them shouldn't be that big of a deal.

    @MovieFan.Plex said:

    But any content you added posters to, edited titles or tags, or did a "fix incorrect match" on won't be matched correctly no matter how closely you follow the above article. Please correct me if I'm wrong, but I have tried following the article multiple times and everytime I've reverted to my backup because my manual changes haven't been noticed.

    Can you give an exact example of a movie, including filename and full before and after paths?

    Here are just two of the numerous examples of me repeating the steps in the article (and yes most of the movies rematched just fine and indeed showed a little blue 2 icon - but it's easy to find the ones that failed; no blue 2 icon):
    /Users/jelwell/Shared/63 Minutes Later (360p).mp4 (original location)
    /Volumes/Movies/63 Minutes Later (360p).mp4 (copy)

    /Users/jelwell/Shared/Hall of Fame/Blame_It_On_Rio_1984.mkv (original location)
    /Volumes/Movies/Hall of Fame/Blame_It_On_Rio_1984.mkv (copy gets named "Hall of Fame")

    I would have to manually edit these (and many more). Neither movie was matched to the original. I think what you and others are attempting to purport is that I should change my workflow so that I edit filenames rather than use plex web to search/match/edit things. I have 2 problems with this suggestion.
    1. I can't go back in time. So there's already a lot of wasted work.
    2. In attempting to rename files I will be guessing what Plex wants the file to be called. A lot of times the movies in question are obscure or have alternate titles (especially different languages). And my file manager isn't as helpful as Plex Web's built in search features.

    Thanks,
    Joseph Elwell.

  • PlexhilaratedPlexhilarated Plexperimentalist Posts: 1,620Members, Plex Pass Plex Pass

    Or... perhaps the Plex "lock" mechanism could actually LOCK things?
    That would be nice too.

    [Peeve of mine]

    My Current Plexistence:
    Server: Intel i5, 14x3TB Internal Drives, Win-10, running PMS, PlexPy, PlexWeb, PHT, PMP, Plex for Windows 
    27" Samsung Monitor and Vivitek HD/3D Projector, 10' Diagonal Fixed Screen
    Dell Laptop: Win-10, running PlexWeb, PHT, PMP, and Plex for Windows
    Samsung 55" LED TV: Samsung Plex App
    Vizio 50" UHD TV: Vizio Plex App
    Samsung 40" LED TV: Samsung Plex App
    Tablet PC: Windows 8.1 Mobile App
    Motorola Droid: Android App
  • jelwelljelwell Posts: 38Members, Plex Pass Plex Pass

    I opened up my database using http://sqlitebrowser.org/
    I manually updated section_locations using the tool. Then I ran these 3 SQL statements:

    <br /> UPDATE metadata_items<br /> SET guid= replace(guid, 'file:///Users/jelwell/Shared', 'file:///Volumes/Movies')<br /> where guid like '%file:///Users/jelwell/Shared%'<br />
    <br /> UPDATE media_streams<br /> SET url= replace(url, 'file:///Users/jelwell/Shared', 'file:///Volumes/Movies')<br /> where url like '%file:///Users/jelwell/Shared%'<br />
    <br /> UPDATE media_parts<br /> SET file= replace(file, '/Users/jelwell/Shared', '/Volumes/Movies')<br /> where file like '%/Users/jelwell/Shared%'<br />

    Note that media_part uses a different reference notation than the rests. (no file:///).

    I haven't been able to drop the changes in place yet. I will try that later and report back.
    Thanks,
    Joseph Elwell.

  • MovieFan.PlexMovieFan.Plex Posts: 15,887Members, Plex Pass, Plex Ninja Plex Employee

    @MovieFan.Plex might be worth adding to your tool?
    Thanks everyone, I can't believe how simple it is and how inaccurate that article is. Might be a good idea to just implement a move function in Plex Web...
    Joseph Elwell.

    :-\"

    > @jelwell said:

  • jelwelljelwell Posts: 38Members, Plex Pass Plex Pass

    @MovieFan.Plex said:

    @MovieFan.Plex might be worth adding to your tool?
    Thanks everyone, I can't believe how simple it is and how inaccurate that article is. Might be a good idea to just implement a move function in Plex Web...
    Joseph Elwell.

    :-\"

    > @jelwell said:

    I'm sure many people will thank you for adding this.
    Joseph Elwell.

  • PlexhilaratedPlexhilarated Plexperimentalist Posts: 1,620Members, Plex Pass Plex Pass

    Thank you for adding that.

    My Current Plexistence:
    Server: Intel i5, 14x3TB Internal Drives, Win-10, running PMS, PlexPy, PlexWeb, PHT, PMP, Plex for Windows 
    27" Samsung Monitor and Vivitek HD/3D Projector, 10' Diagonal Fixed Screen
    Dell Laptop: Win-10, running PlexWeb, PHT, PMP, and Plex for Windows
    Samsung 55" LED TV: Samsung Plex App
    Vizio 50" UHD TV: Vizio Plex App
    Samsung 40" LED TV: Samsung Plex App
    Tablet PC: Windows 8.1 Mobile App
    Motorola Droid: Android App
  • jelwelljelwell Posts: 38Members, Plex Pass Plex Pass

    Doesn't look like there is a way to mark that I answered my own question. Which really isn't very surprising. Until MovieFan.Plex's new database tool is released, you can follow my SQL based solution above.
    Joseph Elwell.

  • beameupbeameup Posts: 7Members, Plex Pass Plex Pass

    Thanks for all the info. I'm about to attempt moving my library from a router shared HDD to a Firewire HDD connected straight to the computer. I'll try moving just the music first. add the path as an addition to the current library and see how it goes.

    Plex Media Server is a Headless 2011 MacMini with 16GB Ram, Intel Graphics.
    Also doubles as an ITunes server for my AppleTV Content.
    Media is stored on a 2TB OWC Elite Firewire drive.
    2 TV playback devices: A Nexus Player on a 55" Sanyo Plasma and the New AppleTv on a 65" LG LED.
    My 42" LG LED is a Smart TV. Also use my IPad 2 and a Nexus 6 phone.

  • rcorkrcork Posts: 440Members, Plex Pass Plex Pass

    I'm so glad i found this thread. I tried following the support topic to move media and even though i followed it exactly, a lot of my media got added as new and not matched to the original media. Editing the database worked perfectly.

    One minor difference i found with my database is that in the metadata_items table, the guid field uses a url encoding scheme so spaces are represented as %20. So i had to modify the command slightly since my original and target folders have spaces in the paths.

  • CilowCilow Posts: 52Members, Plex Pass Plex Pass
    edited April 2016

    If i open the .db File with SQLite, how exactly can i change/find the Things need to be changed?

  • MovieFan.PlexMovieFan.Plex Posts: 15,887Members, Plex Pass, Plex Ninja Plex Employee

    @Cilow said:
    If i open the .db File with SQLite, how exactly can i change/find the Things need to be changed?

    See the selected answered post above.

  • CilowCilow Posts: 52Members, Plex Pass Plex Pass

    All i want to know is how can i find:
    UPDATE section_locations
    SET root_path= replace(root_path, '/Users/jelwell/Shared', '/Volumes/Movies')
    where root_path like '%/Users/jelwell/Shared%'

    ??
    I'm not so familiar with SQLite, as i use it the first time.

  • MovieFan.PlexMovieFan.Plex Posts: 15,887Members, Plex Pass, Plex Ninja Plex Employee

    Not sure what you mean by find. You just type that command replacement the paths with the old and new paths that you have. In the example "/users/..." is the old path, "/movies/..." is the new path.

    If you are not familiar with salute, make a backup. You can really mess up your database if you do things wrong.

  • YamiWheelerYamiWheeler Posts: 6Members ✭✭

    This is not user friendly at all. :/ Shouldn't have to go through all of this nonsense just to retain some metadata.

«1
Sign In or Register to comment.