Created
September 28, 2016 09:00
-
-
Save wis/868a7c8d4543713d741dfb7139fdcaeb to your computer and use it in GitHub Desktop.
Powershell script to get the total length of all videos in Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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