Skip Navigation

TV Show Episode Names and Filename Sorting

This post is a lament about how episode names and file-name conventions interact to result in horrible sorting of tv-show filenames in the filesystem.

The Jellyfin TV Show docs show a preferred filename format like Episode S00E01.mkv. The docs aren't really clear about what the string Episode is supposed to represent here, though. Is that the show name, the episode name, or something else?

  • The example in the multi-part episode docs gives us a hint a hint that it's really intended to be the series name like Series (2010) S02E01<separator><parttype><separator><partnumber>.mkv.
  • The tests in the source code make this even clearer with examples like the_simpsons-s02e01_18536.mp4 and the.series.name.s01e04.webrip.x264-Baz[Bar].mkv. Plus the variable is called SeriesName in the tests.

Interestingly, that string shows up in the episode name in the Jellyfin UI if your series isn't in tvdb. So it can be very useful to set episode-names. But if you do this, the filesystem sort order gets pretty miserable, like:

 
    
$ ls 'my show (2023)/'
'bar - S01E02.mp4'
'baz but this episode name is longer - S01E03.mp4'
'episode foo - S01E01.mp4'

  

If there are 10 or more episodes, and the episode names vary in length so the season/episode strings don't line up vertically, it's very difficult to read the episode order. It would be so nice if S01E01 My Episode Name.mkv was supported. And this is even nodded to in the tests, but commented out as it apparently does work. And in this case the show name is pulled from the directory and the episode is ignored.

I guess maybe this is lamenting the lack of proper episode name support in tv show filenames. Though abusing the current SeriesName works... it makes the filesystem sorting gross.

5 comments
  • If it's just about the filesystem sorting that is a problem you could also define an alias that sorts the files in your current folder by the back of the file name:

    alias jf-ls="ls -lah | rev | sort | rev"

     
        
    [root@worker01 test]# jf-ls
    drwxr-xr-x 2 root root  5 Jun  6 09:29 .
    dr-xr-x--- 5 root root 17 Jun  6 09:29 ..
    -rw-r--r-- 1 root root  0 Jun  6 09:29 episode foo - S01E01.mp4
    -rw-r--r-- 1 root root  0 Jun  6 09:29 bar - S01E02.mp4
    -rw-r--r-- 1 root root  0 Jun  6 09:29 baz but this episode name is longer - S01E03.mp4
    total 19K
    
      

    I personally don't really care about the episode names and just use the series name so they are sorted properly.

    I have also seen a few people put the episode name in the back like this:

    Fear.the.Walking.Dead.S01E02.So.Close.Yet.So.Far.1080p.mkv

    Jellyfin parses this with no issue.