Naming video files/TV shows

From Official Kodi Wiki
Jump to: navigation, search
Steps to create your Video Library
1. Video Guide Main Page
Prepare the Files
2. Naming & Folder Structure
2.1 Movies
2.2 TV Shows

Creating the Library
3. Add Sources & Scrape
4. Scraping Problems
Modify your Library
5. Update Video Library
6. Library Management
7. Artwork
7.1 Movie
7.2 TV Show
8. NFO Files
8.1 Movie
8.2 TV Show

Safeguard & Rebuild
9. Import-Export Library
10. Backup
Home icon grey.png   ▶ Video library ▶ Naming video files ▶ TV shows

1 Introduction

Setting up TV Shows correctly is a little bit more involved than the Movies section. The first part of this page will describe the Kodi best practice to name TV Shows and Episode files and to create the folder structure to save them in. These methods are proven to be the simplest and most robust method which provides the most accurate scrape.

2 TV Show Folder

Video-TVShow Folder.png

Each TV Show requires its own folder. The TV Show folder name is used to match the show at the scraper site..

Kodi does not support the flat folder structure for TV Shows where all episodes from different TV Shows are in the same folder.

  • The TV Show folders are located inside the Source folder.
  • The folder name will be cleaned of commonly used strings, such as DVDRip, 1080p, x264, etc. before being passed to the scraper. If the year of release is included, this will be extracted and used by the scraper to assist in making a match.
  • Spaces, periods, or underscores may be used to separate words in the folder and file names, but should not be mixed. Note also the issue with Split-episodes regarding file names with periods.

Naming TV Shows follows the same guidelines as for Movies.

  • Name the TV Show folder the same way as shown on the TV Show page at the scraper site.
  • It is always best practice to include the year along with the title. This makes scraping more accurate and differentiates between original and remake versions.
  • This guideline also applies to Country of Origin TV Shows. For example Hells Kitchen (UK), Hells Kitchen (US), Hells Kitchen (AU), Hells Kitchen (IT) etc.
  • The title and (year) displayed at the scraper site is how you should name your show.

The best practice method is detailed in the image to the right. (season folders are optional)

  • Angel (1999)- TV Show folder containing Single File episodes
  • Battlestar Galactica (1978)- TV Show folder containing DVD folders for episodes
  • Battlestar Galactica (2004)- TV Show folder containing Bluray folders for episodes

2.1 Split folders

Split folders are TV Shows that have episodes split between two or more folders located in different Sources. This may occur when a long running show is progressively saved on one drive but, over time, the drive has been filled with other content, forcing you to save new episodes on another drive.

To ensure these split TV Shows are correctly scraped as the same show, you must ensure that the TV Show folder names are identical. A slight variance could see a different show scraped for the second folder. If using NFO Files, then copy the NFO file from one location into the other split folders.

3 Season Folder

Season folders are optional. They are useful to reduce clutter in the main TV Show folder.

Even though Kodi can accommodate the Season folder, it will ignore them. Instead it looks for the correctly numbered episode files.

As a side note, once your TV Shows have been scanned into the Library, it is possible to rename the Season folder displayed by Kodi. See: Season Rename

When scraping be aware that season numbers may not be basic numbers. Many shows use the Year as the season number. This is quite common with older shows, daytime soaps and talk shows. Always check the site

4 Episode Files

Check the site of the information provider to confirm your files are in the same order and that the episodes exist at the scraper site. If not, images and metadata will not match your episode files or your scrape will fail if the episodes do not exist.

  • The episode files (or folders if using DVD or Bluray folders) are located inside the TV Show folder or inside Season folders if using them.
  • The file name (or folder name) will be cleaned of commonly used strings, such as DVDRip, 1080p, x264, etc. before being passed to the scraper.
  • Spaces, periods, or underscores may be used to separate words in the folder and file names, but should not be mixed. Note also the issue with Split-episodes regarding file names with periods.

All episode files must be named and numbered correctly for the scanner to match the correct episode to the <episodeguide> URL of the TV Show downloaded from the scraper site. You cannot nominate season and episode numbering through NFO Files.

The following is the simplest and most accurate way to name your episode files:

Angel (1999) S01E01.mkv
Where: Angel (1999) = TV Show name
S01E01 = Season 1, Episode 1

For information on alternate or advanced episode naming conventions, see the Advanced Setup section further down this page.

For information on alternate episode orders, see the Episode Groups section further down this page.

4.1 Specials Episodes

All Special Episodes use Season 00

Doctor Who (2005) S00E50

They are listed at TheMovieDB in the Specials section of the Season listing.

Special Episdes are episodes that do not fit into the normal storyline of the TV Show. They may include items such as Christmas Specials, Season recap episodes, Made for TV Movies that extend the storyline, Unaired Pilots etc

Special Episodes can be displayed in amongst the regular episodes through the use of NFO Files. this is specified using the <displayepisode></displayepisode> and <displayseason></displayseason> tags.

5 Episode Groups

Episode Groups or Orders are listings with alternate episode orders. Some TV Shows are broadcast in one order but the DVD/Bluray release may have a different screening order. A well known example is the TV Show Firefly where the Studio opted to broadcast high action episodes for ratings first, while the Producer wanted a different order to correctly unfold the storyline.

5.1 TheMovieDB-TV Shows

TheMovieDB uses Episode Groups for additional episode orders.

  • Numerous Groups can be added which should cater to the different releases between countries
  • Creating Groups and adding episodes is quite simplistic, using drag and drop which should encourage contributors to complete the entries
  • Where available, the listings are easily accessible for viewing as shown in the images below

To use one of the orders for scraping, follow the images above and place the address in a Parsing NFO file then scrape. The Parsing NFO File will point the scraper to the listing. [1]

5.2 The TVDB

The TVDB allows for three listing orders as detailed below.

  • These are the only three orders available.
  • The current web site is flawed and does not allow the display of the different orders.

Aired Order
  • This is the default order set in the scraper settings.
  • TVDB lists all TV shows in the original Aired Order. The first time a show is ever broadcast, that is the listing shown. The site is not concerned with how it was broadcast the 2nd, 3rd or 15th time, or how it was broadcast in other countries, or during syndication. It only lists the order of the FIRST TIME ever broadcast, whether that be on Free To Air or Subscription Television.
  • Episodes are grouped and listed into Seasons and each episode is numbered sequentially from 1, which resets for each season.
Stop hand.png DVD, Absolute and Flexible Orders at TVDB are partly broken. This is not expected to be fixed until the TVDB v4 API is released mid 2021
DVD Order
  • In many cases, DVD's are released with a different episode listing, normally being the original order envisioned by the Director. To accommodate this, the site also has a DVD Order listing.
  • Episodes are grouped and listed into Seasons and each episode is numbered sequentially from 1, which resets for each season.
  • There are many TV Shows on the TVDB site that do not have the DVD Order data entered. The scraper will default back to Aired Order if there is no DVD Order information listed.
  • Note: As the data at TVDB is created by the open community, it is not uncommon for errors to occur with DVD Order details. As it is seen as secondary information, the errors can go unnoticed. One major error that affects the scrapers is incomplete DVD Order details. For example, some episodes have no DVD Order data, while other episodes in the same season do have the data.
  • Early May 2018, TVDB upgraded their website to v2.0. Unfortunately a glitch has prevented the display of DVD Order and Absolute Order information. It is unknown when it will be rectified.
Absolute Order
  • This order ignores Seasons and gives each episode an incremental number starting at 1.
  • This order is used for Anime type shows.

The Order you use can be set in the settings page for the TVDB Scraper.

The remainder of this page deals with Special Use cases and can be safely ignored. Most libraries will not require implementing the following additional name extensions.

Next step: Add Source & Scrape

6 Advanced Setup

The previous section details the simplest method to set up your TV Show library. It is considered the best practice method.

The sections from here onwards are alternate or advanced methods. With added complexity comes higher maintenance and more potential problems and scraping errors.

6.1 TV Show folder

These other methods are available but NOT recommended. The sub-folders are easily mistaken and scraped as false TV shows. While it is possible to find and fix the ghost entries, the extra time and work involved will override any possible benefits. If you need to re-build your library at a later stage, the problems will need to be solved again.

In more complex situations where your top-level directory is further sub-divided before the show folders, you can add the top-level as source but not set the content, and then set the content to TV shows on each sub-folder.

TV Shows                  <<Source folder, Content: None>>
   |----A-M               <<Content: TV shows>>
   |      |----TV Show 1
   |              |--Files
   |----N-Z               <<Content: TV shows>>
   |      |----TV Show 2
   |              |--Files

It is also possible to have a sub-folder group multiple shows together in an otherwise normal directory structure. Just change the content on the sub-folder and de-select the "Selected folder contains a single TV show" setting.

TV Shows                  <<Source folder, Content: TV shows>>
   |----TV Show 1
   |       |----Season #
   |            |--Files
   |----Star Trek Series  <<Content:TV shows>>
   |       |----Star Trek
   |       |       |--Files
   |       |----Star Trek The Next Generation
   |               |--Files

In these cases, it's best to refrain from scanning the files into the library until the content is set correctly for all folders, to avoid incorrect results and the need to rescan.

6.2 Seasons

Nil availble options. Season folders are ignored by Kodi which means you can name them as you please.

6.3 Single Episodes

Episode files are assumed to contain a single episode. If you have files that contain two or more episodes, then read the Multi-Episodes section below.

The structure of the episode name is as follows:

name <<pattern>>.ext
  • name is the title of the show and is optional. It could just as easily be after the pattern, or excluded entirely.
  • <<pattern>> is one of the expressions in the following tables. S = Season number; E = Episode number
  • .ext is a recognized video file extension, (mkv, avi, ts, mp4, etc) or ommitted entirely if using DVD or Bluray folders.

Kodi uses a series of regular expressions to determine the season and episode numbers from the file name. These are checked in a pre-determined order with the first match being the one used and everything else in the file name is ignored. NFO Files are never checked for season and episode numbers.

There are 8 default patterns, plus a separate multi-episode pattern. Using any other numbering convention outside of the ones provided in the list below will require you to edit your advancedsettings.xml and insert your custom RegEx.

Spaces, periods, or underscores may be used to separate words in the folder and file names, but shouldn't be mixed in the same name. The regex is not case-sensitive and either uppercase or lowercase may be used. The examples on this page use uppercase.

The following table lists:

  • The pattern that Kodi will search for.
  • The order of the search. ie. Patterns numbered 1 will be matched first and those numbered 7 will be matched last.
With Season
The most common usage and used for nearly all TV Shows.
No Season
In cases where you only have one season (or are using absolute order in the TVDB scraper), you may want to forego the inclusion of the season number.
By date
Common for long-running daily shows, allows the use of aired date of the episode.
With Season No Season By Date
Order Episode Naming Order Episode Naming Order Episode Naming
1 Name S01E02.ext (most accurate) 2 Name ep02.ext 3 Name
1 Name S1E2.ext 2 Name ep_02.ext 3 Name yyyy-mm-dd.ext
1 Name S01.E02.ext 7 Name E02.ext 4 Name
1 Name S01_E02.ext 7 Name Part II.ext
1 Name S01xE02.ext 7 Name Pt II.ext
5 Name 1x02.ext Name Part II.ext
6 Name 102.ext (least accurate)

6.4 Multi-Episodes

In cases where the file contains more than one episode, it is possible to specify all the episodes included in that file. Everything after the first found pattern match will be checked for further matches to the same pattern.

  • When using a single video file for multiple episodes it is possible to tell Kodi when each episode starts using Episode Bookmarks
  • Two versions are shown- Long version and Short version. Only the episodes in the file name will be added, e.g. name.s01e01-03.ext will not include episode 2.
  • The patterns are the same for Single Episode numbering, but extended to include multiple episodes.
See also: multi-episode pattern
Complex Pattern Short Pattern
Order Example Name Order Example Name
1 name s01e01-s01e02.ext 1 name s01e01e02.ext
1 name s01e01-episode1.title-s01e02-episode2.title.ext 1 name s01e01-02-03.ext
1 name s01e01-s01e02-s01e03.ext 5 name 1x01x02.ext
5 name 1x01-1x02.ext 2 name ep01-02.ext
2 name ep01-ep02.ext

6.5 Split Episodes

Stop hand.png The November 2019 upgrade of the TVDB site has removed the E01.1, E01.2 type numbering of episodes.
This naming technique no longer applies for any scraper and has been removed from the wiki.

If your files still contain this numbering scheme, and you intend to re-scrape your library, check the episode listing at TheTVDB to ensure your episodes are numbered correctly.

7 Stub and Stream Files

If you have a collection of DVD's and Bluray disks but do not want to rip them to a hard drive, then a Media Stub File allows you to add the collection of disks to the Kodi Video Library. It is a simple text based file that is added to your Source in exactly the same way as any other Movie or TV Show, which is then scanned or scraped into the library.

Various internet video and audio streams can be played back in Kodi as if they were locally stored on your media center by using STRM files. As long as the format and streaming-method (network-protocol) is supported by Kodi, stream can be added. These are basic text files that look like <name>.strm and contain a URL to the internet stream. STRM files can also be added to the video library and can have cover art, summaries, etc.

Some internet sites may have an add-on available that can also access these media streams, rather than having to manually create STRM files. See Add-ons for more information on how to find and install add-ons.

8 Media Tags / Flags

480.png 1080.png 720.png 1080 n.png 480-1.png Divx.png Xvid.png H264.png Bluray.png Dvd.png Avc1.png 1.33.png 1.66.png 2.20.png 2.35.png

Media flags are icons in Kodi that displays the meta-information from the media file of a movie, TV show or music title. They are skin specific, and what works in one skin, may not work in another skin. It is always best to check with the skin sub-forum which flags and tags are used.

It is important to note that the skin will display these flags even when these extensions are not used. The only difference being that without the extensions, the movie must be played first in order for Kodi to read the audio and video codec data.

The actual audio and video codec data will override any extension used. This means that if you set the extension of, say, .ATMOS but the video file only has a stereo track, then the .ATMOS flag will be removed.

Example- note that movie folders are used, and the folder is simply named while the filename has been modified with extensions.

...\Paul (2011)\Paul (2011).4K.HDR.Atmos.mkv

8.1 3D Episodes

Some 3D episodes might need an additional file name extension to be identified by Kodi as 3D. See 3D for details on that additional extension, and when it is needed.

9 Custom Filenames

It's possible to use custom file names that don't match any of the default patterns by editing your advancedsettings.xml file to include a tvshowmatching tag containing regular expressions.

A tvshowmatching regexp needs up to three capturing groups:

1 capturing group = episode number (season will default to season 1), no multi-episode matches will be attempted
2 capturing groups = season number + episode number (in that order), no multi-episode matches will be attempted
3 capturing groups = season number + episode number + multi-episode matching part (typically just the remainder of the file name)

(A capturing group is essentially a part of the regexp contained inside brackets.)

To have no season but multi-episode matching, use three groups but leave the first empty.

Date-based regexps are also possible, and are marked by a bydate="true" attribute in the regexp. These also use three capturing groups, either as year-month-day or day-month-year, the lengths must be exactly 4-2-2 or 2-2-4.

Your custom tvshowmatching regexps can be either checked for before the default set using action="prepend", or after using action="append". Not including an action will result in only your regexps being tested. Care should be taken to ensure that the right regexp matches your file names, particularly in regard to the three digit "102" pattern seen above. The regexps should be grouped together inside a single tvshowmatching tag, although you can use two if you wish to prepend and append different regexps.

You can also change the multi-episode matching regexp by including a tvmultipartmatching tag in your advancedsettings.xml (separate from the tvshowmatching tag). There can be only one tvmultipartmatching expression, whatever you use will overwrite the default, so take care to only expand on the default pattern unless you are certain. The tvmultipartmatching requires one capturing group for the episode number.

For simplicity, the split-episode pattern has been excluded from the examples below. To allow for split-episodes, replace the [0-9]+ in the episode capturing group with [0-9]+(?:(?:[a-i]|\.[1-9])(?![0-9]))?

9.1 Examples

A fairly straightforward example to begin.

Season ## - Episode ##
"Season [season#] - Episode [episode#]" anywhere in the file name
 <tvshowmatching action="prepend">
     <regexp>Season ([0-9]+) - Episode ([0-9]+)([^\\/]*)$</regexp>
Example : TV Shows\Scrubs\Season 1\Scrubs - Season 1 - Episode 01 - Pilot.avi
The first two capturing groups should be obvious, the third group ([^\\/]*) captures everything up to the end of the file name $, this allows for multi-part file names such as name.Season 1 - Episode 01 - Season 1 - Episode 02.ext as well as the simpler name.Season 1 - Episode 01-02.ext

The entire file path is passed to the regexps, so care should be taken to ensure the matches can't occur earlier in the path, but this does mean for example, you can capture the season number from a sub-folder name.

\Season #\##
Season [season#] at the end of the directory name, file name starts with [episode#]
 <tvshowmatching action="prepend">
     <regexp>Season[\._ ]([0-9]+)[\\/]([0-9]+)([^\\/]*)$</regexp>
Example : \Battlestar Galactica (2003)\Season 3\01 - Occupation.avi (Season 3, Episode 1)
Again we use three groups here to allow for multi-episode, but in this case (obviously) only the shorter multi-episode pattern can occur, e.g. Season 1\01x02 - Episode title.ext.

For numbering without a season, you should ensure that only the episode number gets matched against and not another number in the title or episode title, or a number as part of a different pattern.

- ## -
" - [episode#] - " anywhere in the file name
 <tvshowmatching action="prepend">
     <regexp> - ()([0-9]+)((?:-[0-9]+)*) - [^\\/]*$</regexp>
Example : \One Piece\One Piece - 099 - Spirit of the Fakes! Heart of the Rebel Army, Kamyu!.avi ("Season 1", Episode 99) (Using Absolute order)
Here, the first capturing group is left empty, and there is a distinct pattern before and after the episode number to ensure only it gets matched. Also instead of capturing the remainder of the file name for multi-part matching, we only capturing a single repeating pattern so only a - 01-02-03 - format will work.

It's also possible to specify a different default season for without-season regexps.

Directory name is Specials, file name starts with [episode#]
 <tvshowmatching action="prepend">
     <regexp defaultseason="0">Specials[\\/]()([0-9]+)([^\\/]*)$</regexp>
Example : \Firefly\Specials\04 - Browncoats Unite.mkv (Season 0, Episode 4)
A combination of the previous two examples, allowing special episodes to reside in a "Specials" folder rather than a "Season 0" folder.

The default date-based regexps only allow for periods or hyphens as delimiters...

[year]_[month]_[day] anywhere in the file name
 <tvshowmatching action="prepend">
     <regexp bydate="true">([0-9]{4})_([0-9]{2})_([0-9]{2})[^\\/]*$</regexp>
Example: : \The Colbert Report\2005_10_17.avi
The exact number of digits is specified for each group to ensure compliance. A separate [month]_[day]_[year] regexp would be needed if both formats are in use.

The default regexps don't allow for DVD folder structures, this can usually be remedied by replacing the final $ with (?:(?:[\\/]video_ts)?[\\/]video_ts\.ifo)$

 <tvshowmatching action="append">
     <regexp>[Ss]([0-9]+)[ ._-]*[Ee]([0-9]+)([^\\/]*)(?:(?:[\\/]VIDEO_TS)?[\\/]VIDEO_TS\.IFO)$</regexp>
Example: \Battlestar Galactica (2003)\The Mini-Series S00E01E02\VIDEO_TS\VIDEO_TS.IFO
The VIDEO_TS folder is optional, e.g. S01E01\VIDEO_TS.IFO will also work.

Similarly for Bluray folder structures, you can replace the final $ with (?:(?:[\\/]bdmv)?[\\/]index\.bdmv)$

 <tvshowmatching action="append">
     <regexp>[\\/\._ \[\(-]([0-9]+)x([0-9]+)([^\\/]*)(?:(?:[\\/]bdmv)?[\\/]index\.bdmv)$</regexp>
With Bluray folders, you'll also run into trouble with the various mpls and m2ts files incorrectly matching other patterns, so you should also exclude all the other folders and files from being scanned:
    <excludetvshowsfromscan action="append">

Finally, a tvmultipartmatching example.

Multiple episode numbers, separated by a + sign
Example: : \Lost\Lost.S01E23+24.Exodus.mkv
In this case we can simply add the + sign to the default symbols, thus preserving the defaults as well.

10 advancedsettings.xml

The following settings allow user customisation for TV Show and Episode matching.

11 References

Return to top

Next step: Add Source & Scrape