Last active
April 6, 2018 05:29
-
-
Save kerbrose/9853e9330ed85d7ef92ebdec4aa70c2f to your computer and use it in GitHub Desktop.
this script will help you to get duration of video in the 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
Function Get-VideoDetails { | |
param ($targetDirectory) | |
$LengthColumn = 27 | |
$objShell = New-Object -ComObject Shell.Application | |
$total_duration = [timespan] '00:00:00' | |
Get-ChildItem -LiteralPath $targetDirectory -Include *.mp4 -Recurse -Force | ForEach { | |
if ($_.Extension -eq ".mp4"){ | |
$objFolder = $objShell.Namespace($_.DirectoryName) | |
$objFile = $objFolder.ParseName($_.Name) | |
$Duration = $objFolder.GetDetailsOf($objFile, $LengthColumn) | |
$time_span = [timespan]$Duration | |
$total_duration += $time_span | |
New-Object PSObject -Property @{ | |
Name = $_.Name | |
Duration = $time_span | |
} | |
} | |
} | |
Write-Output $total_duration.ToString() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment