# Scan/Refresh Directory via Command Line (Plex Home Server)

**URL:** <https://forums.plex.tv/t/scan-refresh-directory-via-command-line-plex-home-server/175502>\
**Category:** General Discussions\
**Created:** [January 12, 2017, 4:55am UTC](https://forums.plex.tv/t/scan-refresh-directory-via-command-line-plex-home-server/175502 "2017-01-12T04:55:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrobplex](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mrobplex/32/15351_2.png) [@mrobplex](https://forums.plex.tv/u/mrobplex)\
**Post date:** [January 12, 2017, 4:55am UTC](https://forums.plex.tv/t/scan-refresh-directory-via-command-line-plex-home-server/175502/1 "2017-01-12T04:55:42Z")

</div>

I am trying to Scan/Refresh a single directory under my TV section “programmatically”. From looking at the documentation, there appears to be 2 options to interact with the Plex Media Scanner (Command Line or Server URL Commands). Based on the examples provided by Plex Support, the following Command Line should accomplish this:

/path/to/Plex\ Media\ Scanner --scan --refresh --section 2 -d /media/tv/show1

However, issuing this command on a Plex Home Server via Command Line errors with “Error: Section doesn’t exist.”

I believe this is because interaction with a Plex Home Server instance requires an authentication token (X-Plex-Token) to be included along with the request. However, I see no way to include this in the Command Line documentation.

So my question is…

1. Can an authentication token (X-Plex-Token) be included in a Command Line request? If so, what is the syntax?
2. Alternately if using URL Commands ([http://127.0.0.1:32400/library/sections/2/refresh?X-Plex-Token=XxXxXxXxXxXxXxXxXx](http://127.0.0.1:32400/library/sections/2/refresh?X-Plex-Token=XxXxXxXxXxXxXxXxXx)), is there a way to specify a directory under the section to scan/refresh using URL Commands?

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Kraevin](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/kraevin/32/96968_2.png) [@Kraevin](https://forums.plex.tv/u/Kraevin)\
**Post date:** [January 12, 2017, 5:10am UTC](https://forums.plex.tv/t/scan-refresh-directory-via-command-line-plex-home-server/175502/2 "2017-01-12T05:10:57Z")

</div>

did you do the --list command first to see which section your tv shows are? it will probably be a different # for you

```
"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --list

```

also this is what works for me on directory

> “C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe” --verbose --scan --refresh --section 1 --directory “C:\Media\TV Shows\Arrow”

---

<div class="post-metadata">

**Author:** ![mrobplex](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mrobplex/32/15351_2.png) [@mrobplex](https://forums.plex.tv/u/mrobplex)\
**Post date:** [January 12, 2017, 6:30am UTC](https://forums.plex.tv/t/scan-refresh-directory-via-command-line-plex-home-server/175502/3 "2017-01-12T06:30:23Z")

</div>

@Kraevin  
Thanks for your response. Yes, when issuing /path/to/Plex\ Media\ Scanner --list from the Command Line, no results are returned. After googling, I was able to determine this was a result of my server being in a Plex Home. This requires an authentication token (X-Plex-Token) to be sent along with every request. I was able to get a list of my Libraries/Sections via the following Plex URL Command:

```
http://192.x.x.x:32400/library/sections?X-Plex-Token=XxXxXxXxXxXxXxXxXx

```

Which returned Id=2 for my TV Library/Section. However, to the best of my knowledge the Plex URL Command interface does not support providing a directory to the scan/refresh command. Providing a directory is only documented under the Command Line interface (as in the sample you provided). My belief is that when I executed the following Command Line interface command:

```
/path/to/Plex\ Media\ Scanner --scan --refresh --section 2 -d /media/tv/show1 

```

The error returned (“Error: Section doesn’t exist.”) is really a bogus error masking the real error being “Access Denied” since I didn’t include an authentication token (X-Plex-Token). Executing any command via the Command Line interface (other than --help) either returns nothing or a bogus error masking “access denied”. Therefore, that leaves me 2 options to execute a scan/refresh at a DIRECTORY level:

Passing an authentication token (X-Plex-Token) via the Command Interface (which supports providing a directory)…BUT I don’t know IF an authentication token can be passed (or the appropriate syntax).

-OR-

Using URL Commands (which support passing an authentication token (X-Plex-Token) )…BUT not sure how to provide a directory with the scan/refresh command.

---

<div class="post-metadata">

**Author:** ![mrobplex](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mrobplex/32/15351_2.png) [@mrobplex](https://forums.plex.tv/u/mrobplex)\
**Post date:** [January 14, 2017, 5:56am UTC](https://forums.plex.tv/t/scan-refresh-directory-via-command-line-plex-home-server/175502/4 "2017-01-14T05:56:56Z")

</div>

Merged into the following thread…

[Plex Media Scanner --list does not return anything [NOT SOLVED]](http://forums.plex.tv/discussion/comment/1346603/#Comment_1346603 "forums.plex.tv/discussion/comment/1346603/#Comment\_1346603")

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [January 7, 2020, 10:34pm UTC](https://forums.plex.tv/t/scan-refresh-directory-via-command-line-plex-home-server/175502/5 "2020-01-07T22:34:36Z")

</div>


