Skip to content

Instantly share code, notes, and snippets.

@wis
Created September 28, 2016 09:00
Show Gist options
  • Save wis/868a7c8d4543713d741dfb7139fdcaeb to your computer and use it in GitHub Desktop.
Save wis/868a7c8d4543713d741dfb7139fdcaeb to your computer and use it in GitHub Desktop.
Powershell script to get the total length of all videos in Directory
# Needs the path where your dll is
Add-Type -Path "C:\taglib-sharp.dll"
Function Get-VideoDetails {
param ($targetDirectory)
Get-ChildItem $targetDirectory -Include *.mp4 -Recurse -Force | ForEach {
$video = [TagLib.File]::Create($_.FullName)
New-Object PSObject -Property @{
Name = $_.FullName
Duration = $video.Properties.Duration.TotalMinutes
}
}
}
# Supply your video directory
Get-VideoDetails "C:\Users\Wesam\Documents\MEGA\EggHead\Courses" | Sort Duration -Descending | Group-Object Item | %{
New-Object psobject -Property @{
Item = $_.Name
Sum = ($_.Group | Measure-Object Duration -Sum).Sum
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment