How to Scan a Library
If you add or delete media from a library you will want to perform a scan against the library to update the changes in your Plex server. If you don't run a scan, then the media won't be available until the next scheduled scan, or until you run it manually.
Plex provides several different ways for scanning the libraries on your Plex server. The following sections will detail the various methods you can use to update your Plex server when media is added or deleted on your server.
Scan a library using the Web app
The easiest method of scanning a library in Plex is to use the Web app. This is the most common method to update a library when a media item has been added.
To scan a library using the Web app, do the following:
- Open the Plex Web app in a browser and log in as an administrative user.
- Move the mouse over the library on the left, and then click the three dots that appear. From the popup menu, click the Scan Library Files option.
Once the above option is selected, the Activity icon in the upper right will indicate that the library scanning is being run. Once completed, the library will include any new media items added.
Scan a library automatically
If you don't want to bother manually scanning libraries when you change media, you can have Plex automatically scan the libraries when it detects changes to the library folders.
If you change media frequently and want the library to reflect the changes sooner rather than later, then this is a good option to enable. Keep in mind though, that if you have a large library then this could take some time to complete, and use server resources in the process.
If you wish to enable this option, you can use the following steps:
- Log into your Plex server as an administrator, and then click the Settings - the wrench - link in the upper-right corner of the Plex server page.
- On the left menu, click the Library option under the Settings section.
- Check the Scan my library automatically option.
- Scroll down to the bottom of the page and then click the Save Changes button at the bottom of the page.
With the option now enabled, Plex will automatically scan the library if any changes to the underlying folders are detected.
Periodically scan libraries
In addition to Plex automatically scanning a library when a change happens, you can have Plex periodically run a scan for your libraries. This means that Plex will perform a library scan at a specified interval. This also means that any added media won't appear in Plex until the scan has run if you don't run it manually before.
If you wish to have Plex run a periodic library scan, use the following steps:
- Log into your Plex server as an administrator, and then click the Settings - the wrench - link in the upper-right corner of the Plex server page.
- On the left menu, click the Library option under the Settings section.
- Check the Scan my library periodically option.
- Select from one of the following intervals:
- every 15 minutes
- every 30 minutes
- hourly
- every 2 hours
- every 6 hours
- every 12 hours
- daily
- Scroll down to the bottom of the page and then click the Save Changes button at the bottom of the page.
You can set the interval based on how often you update your media and how much your Plex server is in use.
Scanning using the API
You can use the Plex API to scan a library or all libraries on your Plex server. The commands can be run from a Web browser, another application, such as Postman, or from your own application developed in a language of your choice.
There are two API commands you can use to scan libraries in Plex:
- Scanning all libraries. This option will scan all the libraries in your Plex server, and will take the most time and server resources.
- Scanning a single library. Only scan a single library in your Plex server.
- Scanning a partial library. Scan a single folder associated with a library.
If you have developed applications in the past, you can always create an application that calls the above two API commands. You can then schedule that application to run a scan when you prefer.
Another option, and the last one, is to use the Plex Media Scanner that is installed with the Plex Media Server.
Scanner via Command Line
The scanning functionality has been deprecated and is no longer available. If you are running an older version of Plex, you may still be able to use this functionality.
The scanning functionality can be run from the command line using the Plex Media Scanner executable. This executable is located in the following default locations:
Operating System | Location |
---|---|
Windows | C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe (32-bit) C:\Program Files\Plex\Plex Media Server\Plex Media Scanner.exe (64-bit) |
OS X | /Applications/Plex Media Server.app/Contents/MacOS/Plex Media Scanner |
Linux | /usr/lib/plexmediaserver/Plex Media Scanner |
Before running the scanner from the command line to scan a library, you will need to know the section ID associated with the library. This section ID can be determined by running the following command at a terminal or command prompt:
{plex_media_scanner_path} --list
The output will list all the libraries on your Plex server along with their associated ID. You will use this ID when running the scanner for a library.
If you are good at development then you can also use the Libraries API command to get the unique identifiers for all the libraries, as well.
Plex allows the following scans to be performed from the command line:
- All libraries.
- A single library.
- A folder within a library.
The three scans listed above are ordered by the amount of time needed to run a scan. Scanning all libraries will take considerably longer, especially for large libraries, than a single folder.
If you only added a single media item, then you may want to scan just the folder containing that item.
For situations where you have deleted a media item or multiple items, you should run the scan for the library that contained those items. You may need to empty the trash if you have disabled Plex to automatically empty trash after every scan, though.
The commands for the three types of scans are listed below.
Scan all libraries
To scan all libraries from the command line, you just run the scanner with the --scan
argument:
{plex_media_scanner_path} --scan
Scan a single library
To scan a single library, you will need the library ID as mentioned above, and then pass that as an argument:
{plex_media_scanner_path} --scan --section {id}
Scan a folder in a library
To scan a single folder in the library, you will need the library ID as mentioned above, and the full path to the folder:
{plex_media_scanner_path} --scan --section {id} --directory "{path}"