# Format Expressions User defined episode / movie naming scheme

## About

You can easily define your own episode and movie naming schemes. It uses Groovy expressions, which means that you can do pretty much anything, especially if you know a little bit about programming. You even get media info bindings. You can find predefined format expressions for all kinds of scenarios in the forums. Ready for you to just copy & paste.

## Examples

`{n} - {s00e00} - {t}`Dark Angel - S03E01 - Labyrinth

`V:/TV Shows/{n}/Season {s}/{sxe} - {t}`V:\TV Shows\Dark Angel\Season 3\3x01 - Labyrinth

`{n.space('.').lower()}.{s}{e.pad(2)}`dark.angel.301

`{n} ({y}){" CD$pi"}`The Man from Earth (2007) CD1

`{n} [{y}] {vf} {af}`The Man from Earth [2007] 720p 6ch

## Advanced Examples

`{n.upperInitial().space('.')}.{y}.{source}.{vc}{'-'+group}`The.Man.From.Earth.2007.DVDRip.XviD-ALLiANCE

`{n} ({y}) by {director} [{genres[0]}, {certification}, {rating}]`The Terminator (1984) by James Cameron [Action, PG-13, 8.5]

`{n.space('_')}_-_{e.pad(2)}_[{resolution}_{vc}_{ac}][{crc32}]`Juuni_Kokuki_-_01_[1280x720_XviD_MP3][3E16AF40]

`{n.space('.')}.{'s'+s.pad(2)}e{e.pad(2)}.{t.space('.')}.{vf}.{vc}.{ac}`Firefly.s01e01.Serenity.720p.x264.ac3

`{n} [{airdate.format('yyyy.MM.dd')}] {t}`The Daily Show [2010.01.05] George Lucas

`E:/Complete/{n} ({y}){'/Season '+s}/{s+'x'}{e.pad(2)} - {t}`Rename and move files. The directory structure is completely up to you.

`{n.replaceTrailingBrackets()} - {s+'x'}{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'")
.lowerTrail().replacePart(', Part $1')}`My personal favorite. Pretty much 1x01, normalizing accents, and lots of other cleanup operations.

## Binding Reference source

Name | Description | Example
--- | --- | ---
n | series/movie name | Dark Angel
y | series/movie year | 2009
s | season number | 3
e | episode number | 1
t | episode title | Labyrinth
airdate | episode airdate | 2009-06-01
absolute | absolute episode number | 42
special | special number | 1
ny | name (year) | Avatar (2009)
sxe | season / episode numbers | 1x01
s00e00 | season / episode numbers | S01E01
plex | Plex Naming Standard | <path>
imdbid | imdb id | tt0756683
vc | video codec | x264
ac | audio codec | ac3
cf | container format | mkv
vf | standard video format | 720p
hpi | exact video format | 384p
af | audio channels | 6ch
channels | audio channels | 5.1
resolution | video size | 1280x720
bitdepth | video bitdepth | 10
kbps | bitrate in kb/s | 320 kbps
khz | sampling rate | 44.1 kHz
minutes | Duration in minutes | 42
ws | widescreen tag | WS
hd | UHD/HD/SD video | HD
s3d | Stereoscopic 3D tag | 3D SBS
source | source medium | BluRay
group | release group | ALLiANCE
crc32 | crc32 checksum | 3E16AF40
gigabytes | Filesize in gigabytes | 4.2
fn | original filename | Serenity
ext | file extension | mkv
episode | episode object | <default episode name>
movie | movie object | <default movie name>
pi | movie part index | 1
pn | movie part count | 2
lang | language tag | eng
subt | subtitle tags | .eng.forced
collection | movie set | Avatar Collection
director | movie director | James Cameron
actors | list of actors | [Sam Worthington, Zoe Saldana, ...]
genre | primary genre | Science Fiction
genres | list of genres | [Science Fiction, Action, ...]
languages | list of spoken languages | [eng]
certification | content rating | PG-13
rating | movie rating | 8.5
info | extended metadata | <any movie / series info>
omdb | OMDb info | <any movie / series info>
home | user home folder | /Users/Alice
file | file object | <file path>
dim | video dimensions | <width and height>
media | general media info object | <any general media parameter>
video | video streams | <any video parameter>
audio | audio streams | <any audio parameter>
text | subtitle streams | <any subtitle parameter>

## Function Reference source

`pad(length, padding = "0")`Pad strings or numbers with given characters ('0' by default).

`match(pattern)`Get a substring matching the given pattern or break.

`matchAll(pattern)`Get a list of substrings matching the given pattern or break.

`space(replacement)`Replace all spaces (e.g. "Doctor Who" ➔ "Doctor_Who").

`colon(replacement)`Replace all colons (e.g. "Sissi: The Young Empress" ➔ "Sissi - The Young Empress").

`slash(replacement)`Replace all slashes (e.g. "V_MPEG4/ISO/AVC" ➔ "V_MPEG4.ISO.AVC").

`upperInitial()`Upper-case all initials (e.g. "The Day a new Demon was born" ➔ "The Day A New Demon Was Born").

`lowerTrail()`Lower-case all letters that are not initials (e.g. "Gundam SEED" ➔ "Gundam Seed").

`acronym()`Get acronym, i.e. first letter of each word. (e.g. "Deep Space 9" ➔ "DS9").

`roman()`Replace numbers 1..12 with roman numerals (e.g. "Star Wars: Episode 4" ➔ "Star Wars: Episode IV").

`before(pattern)`Get the substring before the given pattern or the original value.

`after(pattern)`Get the substring after the given pattern or the original value.

`replaceAll(pattern, replacement = "")`Replace or remove all occurrences of the pattern.

`replaceTrailingBrackets(replacement = "")`Replace trailing parenthesis including any leading whitespace (e.g. "The IT Crowd (UK)" ➔ "The IT Crowd").

`replacePart(replacement = "")`Replace part identifier (e.g. "Today Is the Day (1)" ➔ "Today Is the Day, Part 1").

`ascii()`Convert Unicode to ASCII. (e.g. "Österreich" ➔ "Osterreich" or "カタカナ" ➔ "katakana").

`transliterate(identifier)`Apply any ICU script transliteration. e.g. "中国".transliterate("han-latin") ➔ "zhōng guó".

Need some help getting started? Check the forums.