# Extract Season and Episode from Filename

**URL:** https://community.mp3tag.de/t/extract-season-and-episode-from-filename/12495
**Category:** General Discussion
**Created:** [September 9, 2011, 9:19pm UTC](https://community.mp3tag.de/t/extract-season-and-episode-from-filename/12495 "2011-09-09T21:19:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Glawster](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/8491ac/32.png) [@Glawster](https://community.mp3tag.de/u/Glawster)
#### Post date: [September 9, 2011, 9:19pm UTC](https://community.mp3tag.de/t/extract-season-and-episode-from-filename/12495/1 "2011-09-09T21:19:16Z")

</div>

Hi folks, great application, really powerful... I am afraid I must draw on your expertise however, I have an action group that takes mp4 filenames and extracts TVSHOW, ARTIST, TITLE etc. I want to extract the season and episode number too. It is a well known format

The Vampire Diaries S01E16 Hdtv Xvid-Notv.mp4

(._)\sS\d+e\d+\s(._)

$1 is the programme name  
$2 I use as the title (sometimes it's the title sometimes its not as above).

what variable can I use to get at the S01E01 values? I am not certain what or how $regexp determines the returned parameter values? Any help greatly appreciated.

Glawster

---

<div class="post-metadata">

### Author: ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)
#### Post date: [September 9, 2011, 9:27pm UTC](https://community.mp3tag.de/t/extract-season-and-episode-from-filename/12495/2 "2011-09-09T21:27:48Z")

</div>

Just add more sets of parentheses:

(._)\s(S\d+)(E\d+)\s(._)

They're numbered from left to right, so with the above regex you now have:

$1 is the program name  
$2 is the season  
$3 is the episode  
$4 is the title

---

<div class="post-metadata">

### Author: ![Glawster](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/8491ac/32.png) [@Glawster](https://community.mp3tag.de/u/Glawster)
#### Post date: [September 10, 2011, 9:09am UTC](https://community.mp3tag.de/t/extract-season-and-episode-from-filename/12495/3 "2011-09-10T09:09:19Z")

</div>

Brilliant, works like a charm. Thanks.
