如何列出資料夾下所有影片長度 - Windows

Table of Contents

把以下內容存成 *.ps1 ,放到影片旁邊
對著ps1檔按右鍵 → 用PowerShell執行
win8測過可以,希望 win7也可以
===================================================

$Shell = New-Object -Com "Shell.Application"

dir *.wmv | % {
$File = $Shell.NameSpace($_.DirectoryName).ParseName($_.Name)

$Duration = $File.ExtendedProperty("Duration")

if ($Duration -ne $null ) {
$T = New-TimeSpan -Seconds ($Duration / (1000*1000*10) )
$Time = $T.tostring()
} else {$Time = ""}

"$Time " + $_.name

# 多加的,如果有人需要的話
# $Width = $File.ExtendedProperty("System.Video.FrameWidth")
# $Height = $File.ExtendedProperty("System.Video.FrameHeight")

# WMV之外的影片,系統可能需要裝Codec (不確定…)
# 如果副檔名給錯的話,可能會顯示不出來
# 例如,容器是mp4,副檔名卻用avi

} > 影片時間.txt

ii 影片時間.txt

--

All Comments