I’m attempting to integrate podcasts into Plex so that I can listen to them over my Roku. This is something Plex doesn’t do well yet, but I’m following this tutorial on Reddit
The rename command, which is implemented in perl, can rename the files.
The files should be in a format like this
“podcast name” – “s01e###” – “title”.mp3
the patch – s01e100 – mortal kombat x + halo online.mp3
My goal is to integrate the Escape Pod podcast, so I have the latest Escape Pod download
The first command to run against the filename adds Escape Pod to the beginning and puts the episode number into a Season/Episode format (S01E502)
rename -v ‘s/EP(\d+)_(.*[A-Z].+)\.mp3/Escape Pod – S01E$1 – $2\.mp3/’ EP502_GorlacktheDestroyersAllYouCanEatAdventure.mp3
EP502_GorlacktheDestroyersAllYouCanEatAdventure.mp3 renamed as Escape Pod – S01E502 – GorlacktheDestroyersAllYouCanEatAdventure.mp3
The title is still a little ugly, so we run this command which will add a space in front of each capital letter in the title except the first one.
rename -nv ‘s/([a-z])([A-Z])/$1\ $2/g’ ./Escape\ Pod\ -\ S01E502\ -\ GorlacktheDestroyersAllYouCanEatAdventure.mp3
./Escape Pod – S01E502 – GorlacktheDestroyersAllYouCanEatAdventure.mp3 renamed as ./Escape Pod – S01E502 – Gorlackthe Destroyers All You Can Eat Adventure.mp3
This gets us close. Unfortunately “the” wasn’t capitalized, so it’s not easy to add a space in there.
I ran this command
rename -n ‘s/(the\ )/\ $1/’ *mp3
Escape Pod – S01E502 – Gorlackthe Destroyers All You Can Eat Adventure.mp3 renamed as Escape Pod – S01E502 – Gorlack the Destroyers All You Can Eat Adventure.mp3
which worked in this situation, but it has a good probability for false positives.
This isn’t perfect, but it gets me much closer to where I want to be.