I know that this isn’t a very active topic but I’ll try my luck and hope that there’s someone here who can help.
I’m trying to merge two libraries together and changing where the files are located by editing Plex’s database. I managed to do it but when I initiate a scan Plex deletes movies that were stored in one of the two locations from the library.
I ran this script first to merge the two libraries together
UPDATE section_locations
SET library_section_id = 16
WHERE
library_section_id = 17;
UPDATE directories
SET library_section_id = 16
WHERE
library_section_id = 17;
UPDATE media_items
SET library_section_id = 16
WHERE
library_section_id = 17;
UPDATE media_items
SET section_location_id = 16
WHERE
section_location_id = 17;
UPDATE metadata_item_views
SET library_section_id = 16
WHERE
library_section_id = 17;
UPDATE metadata_items
SET library_section_id = 16
WHERE
library_section_id = 17
Then I ran this script to change the location of the media items in both libraries
UPDATE section_locations
SET root_path= replace(root_path, 'G:\Movies1', 'F:\Movies')
where root_path like '%G:\Movies1%';
UPDATE metadata_items
SET guid= replace(guid, 'file://G:\Movies1', 'file://F:\Movies')
where guid like '%file://G:\Movies1%';
UPDATE media_streams
SET url= replace(url, 'file://G:\Movies1', 'file://F:\Movies')
where url like '%file://G:\Movies1%';
UPDATE media_parts
SET file= replace(file, 'G:\Movies1', 'F:\Movies')
where file like '%G:\Movies1%';
UPDATE section_locations
SET root_path= replace(root_path, 'G:\Movies2', 'F:\Movies')
where root_path like '%G:\Movies2%';
UPDATE metadata_items
SET guid= replace(guid, 'file://G:\Movies2', 'file://F:\Movies')
where guid like '%file://G:\Movies2%';
UPDATE media_streams
SET url= replace(url, 'file://G:\Movies2', 'file://F:\Movies')
where url like '%file://G:\Movies2%';
UPDATE media_parts
SET file= replace(file, 'G:\Movies2', 'F:\Movies')
where file like '%G:\Movies2%'
This merges the two libraries together and changes their location fine. The files all play just fine after this edit, my only problem is that when I initiate a scan Plex deletes the movies that were stored in the first location from my library.
Anyone got any idea what I might be doing wrong?
Thanks for the help.