I recently *ahem* legally acquired 6 seasons of It’s Always Sunny In Philadelphia. I host all my media files in Plex Media Server, so I can stream them to whatever screen I want. Unfortunately, it was unable to recognise the format:

e.g.

Rather than rename 70 episodes to a S01E01 format, I thought I’d try out a little PowerShell. I’d previously used this before, but I can’t exactly remember where I found it online. Google may help.

So, here’s the command:

It’s fairly simple.  dir lists all the files in the directory. It’s passed through to the  rename-item command as (presumably) an array. For each item, the name is filtered through (presumably) some regex. As you can see above, the string “Season ” is replaced with an “S”, and ” Episode ” is replaced with an “E”.

Now all my files are in the format:

Because I had each season separated into folders, I repeated this command 6 times. A smarter way to do this would be to recursively descend the parent directory.

Hopefully none of the episode titles had “Season ” as a word, because that’s now an “S”. The price of laziness.

If you’re wondering how to access PowerShell, open the folder with the files you want to rename. Hold Shift + right-click –> Open PowerShell window here. There’s a ton you can do with PowerShell, but it upsets me. BASH is much nicer in my opinion. Now that I think of it, I could’ve probably done this with the Linux subsystem for Windows. RIP.