Sort Files for Emby

I've been testing using Emby for my media needs since Plex was a bit iffy sometimes, especially on my "smart" TV. Now that I have my gaming PC connected to my TV I can try out new things.

I tried Emby on a server that's always on and holds the media and Kodi on the PC. It works quite ok, but I did have to patch Emby to be a bit smarter about folder names. It expects them to be quite perfect and usually they aren't. More about that later if needed.

The next issue was that Emby skips all videos that are in the root of the video folder. It expects everything to be nicely in folders. So what to do? Fire up PowerShell and get it sorted out! I'm not at all experienced in PowerShell, but this is what I concocted:

Get-ChildItem .\* -include *.mkv, *.mov, *.mp4, *.avi|  ForEach-Object { $dir = (($_.FullName -replace '\.[^.]+$','') -replace 'S[0-9]+E[0-9]+.*$', ''); if(!(Test-Path -Path $dir)) { md -Path $dir|Out-Null }; $dir = Get-Item "$dir"; Move-Item $_.FullName $dir.FullName }

The idea is to take all mkv, mov, mp4, avi files, strip the extension, if they have any series/episode info strip that out too (including anything after it), create folder based on that name and put the files in there.

Works nicely, except for some reason files with angle brackets in them [] don't work. Didn't have many so manual editing was enough.

Now Emby can actually detect all the videos properly. I could've of course patched the code but this was simpler since I don't know much about Emby's internals.

 

Add comment

Loading