Hi all,
I am in the process of moving some TV Show directories around to another hard drive. Lets use this directory structure for reference:
old drive
/mnt/drive1/TV1/showa
/mnt/drive1/TV1/showb
/mnt/drive1/TV1/showc
/mnt/drive1/TV1/showd
new drive
/mnt/drive2/TV2/showz
I am moving the show directory from drive1 to drive 2. I was using the following command
mv /mnt/drive1/TV1/showa/ /mnt/drive2/TV2/
Which seems to have been working fine. No change in “last episode added” and “date added”. Because I wanted to move a little faster (I have 100+ to move) I started using “mc” on linux since it has a pseudo GUI interface for moving files. Problem is now plex is seeing all the files as new episodes/tv shows and showing them when sorted by “last episode date added or date added” at the top. It is correctly marking the ones played that were played, so a win there.
I realize something with mc must have changed the file. What I would like to know is how to manually or with a script update all the episodes “last date added” entry so they are no longer in the top of my list. I just want them something like 6 months back as I don’t need the actual date added. I just don’t want them at the top…
The simplest way, if you’ve ever tinkered with the plex DB, would be -
UPDATE metadata_items SET added_at = md.originally_available_at WHERE added_at <> originally_available_at AND originally_available_at IS NOT NULL and library_section_id=XX;
This would set the date_added to the date when the episode aired
Note, this would change everything in your Library as defined by library_section_id=XX
Actually the fact that mv didn’t cause any problem is the real strange thing.
To move your files you want to go to settings and disable any automatic scan and disable empty trash automatically (the most important one).
Once that’s done, you do the following:
add your second drive to your library. Yes, drive 1 and 2.
Move your files as you prefer
Manually scan your library and wait until Plex detects the new files location. The old path of each Show will be shown as Unavailable. It means that the moving worked.
Remove the old drive from your library.
Now you can empty the library trash
Re-enable the automatic scan and the Automatic trash empty
Thanks hthighway,
I have tried the above SQL using library_section_id=2 (2 is my TV show library). However I get an error: no such column: md.originally_available_at.
I looked at the table and it looks like the column name is without the “md.” So I removed it and ran the command again. Now I get unknown tokenizer: collating
CostaHT,
Once I get the suggestion hthighway’s suggest to work to update what is already messed up to work, I will continue moving items based on your explaination.
I got it figured out. I was using a SQLite3 editor directly, but found that you can’t do it this way. You have to use the built into plex… I have them updated now…
For others that find this later, here is a BASH script I found and modified to do this update.
#!/bin/bash
SQLITE=/usr/lib/plexmediaserver/Plex\ Media\ Server
DB=./com.plexapp.plugins.library.db
cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases
"$SQLITE" --sqlite $DB "UPDATE metadata_items SET added_at = originally_available_at WHERE added_at <> originally_available_at AND originally_available_at IS NOT NULL and library_sectio
n_id=XX;"
I got the correct section number from changing the SQL to SELECT * FROM library_sections;
Thanks for posting this solution. Can the bash script be ran using powershell or command prompt? I’ve always used SQLite3 editor in the past and trying to find the built into plex option.
BASH is a linux shell so you can’t necessarily run it on windows. You MAY be able to get something working using CYGWIN, but I haven’t tried since my plex is on a linux server…
I would imagine, though, the command structure would be similar in the way it is called… If you break the BASH shell script, it is basically doing this:
cd /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases
/usr/lib/plexmediaserver/Plex Media Server --sqlite ./com.plexapp.plugins.library.db UPDATE metadata_items SET added_at = originally_available_at WHERE added_at <> originally_available_at AND originally_available_at IS NOT NULL and library_section_id=XX;
Replace XX with the correct value from:
/usr/lib/plexmediaserver/Plex Media Server --sqlite ./com.plexapp.plugins.library.db SELECT * FROM library_sections;