Influencer Posted November 11, 2014 Share Posted November 11, 2014 I have a mixture of DVD movies and Blu-Ray movies on my server, I think I have most of them sorted but to save from checking every movie does anyone have a script they use to list all media files in a directory with the file name, extension and video/audio codecs? I initially searched for anything that wasn't mkv and went through those, but I've ran across a few MKV's that I ripped a long time ago (when I only had ONE storage drive!) that in order to save space I ripped with lower quality audio losing 5.1 to stereo. Quote Link to comment
StevenD Posted November 11, 2014 Share Posted November 11, 2014 You can do what you want with FileBot. filebot -mediainfo path/to/files --format "{fn} {resolution} {vc} {ac}" I put together a little PowerShell script that queries a share for all the movies, then runs FileBot against each one, and then exports it all out to a CSV. Im sure there are easier ways to do this, but I'm very familiar with PowerShell. $Now = Get-Date -Format yyyy-MM-dd $MovieShare = "\\nas\BluRay" $CSV = "$MovieShare\Movies.$Now.csv" $Movies = @(Get-ChildItem $MovieShare -Directory | Sort-Object) $MovieInfo = @() foreach ($movie in $Movies) { Write-Host "Fetching"$movie.fullname"..." -ForegroundColor Magenta #Finds the largest file $file = $null $file = Get-ChildItem $movie.fullname -file | sort length | select -last 1 $FilePath = $file.fullname $filebot = "C:\Progra~1\FileBot\filebot.exe -mediainfo `"$FilePath`" --format `"{source},{resolution},{vc},{ac}`"" $Return = Invoke-Expression $filebot $Source = ($Return.split(","))[0] $Resolution = ($Return.split(","))[1] $VC = ($Return.split(","))[2] $AC = ($Return.split(","))[3] $file | Add-Member -MemberType NoteProperty -Name Source -Value $Source $file | Add-Member -MemberType NoteProperty -Name Resolution -Value $Resolution $file | Add-Member -MemberType NoteProperty -Name VC -Value $VC $file | Add-Member -MemberType NoteProperty -Name AC -Value $AC $MovieInfo += $file } $MovieInfo | select Name,Directory,Source,Resolution,VC,AC | Sort-Object | Export-Csv $CSV -NoTypeInformation Quote Link to comment
Influencer Posted November 11, 2014 Author Share Posted November 11, 2014 Thanks, looks like thats exactly what I need! Quote Link to comment
Influencer Posted November 11, 2014 Author Share Posted November 11, 2014 Getting an error that the parameter -Directory cannot be found? Ok, changed that to recurse which seemed to work. Now getting the attached errors. Quote Link to comment
StevenD Posted November 12, 2014 Share Posted November 12, 2014 I didnt even think about this... what version of PowerShell are you running? The '-Directory' parameter is only in PS 3.0+. I'm running 4.0. Quote Link to comment
Influencer Posted November 12, 2014 Author Share Posted November 12, 2014 Not sure, lol. I'll check tonight when I get home. I did end up getting it to run but it ran for hours and it never finished fetching the files, I think I got it stuck in an endless loop. Edit: just dialed in and checked. I'm on 2.0, I'll update and try again tonight. Quote Link to comment
StevenD Posted November 12, 2014 Share Posted November 12, 2014 Try changing: $Movies = @(Get-ChildItem $MovieShare -Directory | Sort-Object) to: $Movies = @(Get-ChildItem $MovieShare | ? { $_.PSIsContainer } | Sort-Object) and $file = Get-ChildItem $movie.fullname -file | sort length | select -last 1 to: $file = Get-ChildItem $movie.fullname | ? { !$_.PSIsContainer } | sort length | select -last 1 Quote Link to comment
Influencer Posted November 12, 2014 Author Share Posted November 12, 2014 Updating to PS 4.0 now, if that doesn't work I'll make the changes and see where that leaves me. Thanks for the help, I've got zero powershell experience so your saving me a lot of googling, lol. I know I could script something on the linux side but I don't want to mess with installing the needed packages to get that info. Mainly all of the dependencies for ffmpeg! Quote Link to comment
Influencer Posted November 13, 2014 Author Share Posted November 13, 2014 Worked great! Thanks a lot! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.