使用 CMD:列出資料夾中的所有 Mp4 並列出其持續時間

使用 CMD:列出資料夾中的所有 Mp4 並列出其持續時間

我目前正在使用以下程式碼建立一個file.CSV包含所有 .mp4 標題清單的檔案:

dir /s /b *.mp4 > listmp4.csv

我想將每個影片的持續時間包含在清單中。
我的命令列應該是什麼?

我也想要 CSV 中的這些數字:

在此輸入影像描述

答案1

AFAIK,如果不使用 WScript 腳本,CMD 就無法取得元資料屬性,例如期間,作曲家, 或者位元率。然而,電源外殼確實提供設施收集該資訊。

以下腳本經過改編來自 StackOverflow, 跑進電源外殼,遞歸掃描資料夾並管道資料夾,檔案名稱期間到 CSV。

$Directory = "E:\Audio Files\_.mp3\Albeniz, Isaac"
$Shell = New-Object -ComObject Shell.Application
Get-ChildItem -Path $Directory -Recurse -Force | ForEach 
{
    $Folder = $Shell.Namespace($_.DirectoryName)
    $File = $Folder.ParseName($_.Name)
    $Duration = $Folder.GetDetailsOf($File, 27)
    [PSCustomObject]@{
        Folder = $_.DirectoryName
        Name = $_.Name
        Duration = $Duration}} | Export-Csv -Path "C:/temp/out.csv" -NoTypeInformation

它創建下面顯示的 CSV。

LibreOffice Calc 中顯示的 CSV

根據文件位置和顯示或隱藏元資料的需要修改腳本。

答案2

使用ffprobe.exe (FFmpeg)在資料夾內的循環中,其中包含要列出的文件

@echo off 

cd /d "D:\Path\To\mp4\Videos\Folder\"
set "_ffprobe=C:\Program Files\FFmpeg\Bin\ffprobe.exe"
for /R %%I in (*.mp4)do @for /f eol^=^|delims^=. %%i  in ('
@"%_ffprobe%" -i "%%~fI" -show_entries format^=duration -v quiet ^
-of csv^="p=0" -sexagesimal^|findstr/e .[0-9]')do echo\"%%~nxI",'0%%~i>>".\file.csv"

相關內容