How to Add a Plex Scan Path from Command Line?

Server Version#: 1.16.5.1554 Latest
OS Version#: Linux Ubuntu 18

Hi guys,

I use a lot of scan paths and so I was exploring some of these Plex Media Server CLI commands which I was able to successfully run from the command line…

https://support.plex.tv/articles/201242707-plex-media-scanner-via-command-line/

With that guide, I can accomplish most of those commands including:

su plex -c “/usr/lib/plexmediaserver/Plex\ Media\ Scanner --list”

Which reports back

1: Movies
2: TV Shows

So what I want to accomplish is adding a new scan location for the plex scanner to find media instead of manually adding/browsing for it at the manage library - add folder area in the GUI server software.

I attempted the following command with no output or error however the new scan path was not added.

su plex -c “/usr/lib/plexmediaserver/Plex\ Media\ Scanner --directory /home/testuser/main/1MOVIE-SERVER --section 1”

Any assistance with this would be greatly appreciated.

There is no command line API to add/remove directories from a Library section definition, sorry.

Hi Chuck…

uhh, thats too bad. I see. It’s weird cause you can add a scan path with the add new section command.

So where’s is the data location of these scan paths? I have nearly 50 scan paths for MOVIES and same amount for SHOWS. That’s the most time consuming part during server changes. I didnt see them in preferences.xml which has most of the server settings.

Linux Ubuntu 18 /usr/lib/plexmediaserver/Plex

Are you referring to this?

 Items to which actions apply:

  -c, --section        A library section ID.
  -o, --item           An item ID.
  -d, --directory      A directory path.
  -f, --file           A file.

This is where you can specify an already known path can be called out.

If you are willing to do the SQLite3 work yourself, you can insert the locations into the section_locations table. You’ll need to look at the schema to determine the section ID and other values as they pertain to you but the general format looks like this:

INSERT INTO section_locations VALUES(2,1,'/share/movies2',1,'2019-08-11 23:04:42','2019-08-11 02:21:01','2019-08-11 23:04:42');

This would need be prefaced by creating the actual section and using that section ID in the above insert statements.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.