腳本用途:
讀取音訊檔案並建立包含歌曲名稱和每首歌曲的 LUFS 值的自訂報告。
問題:
當歌曲名稱太長時,LUFS 值欄位會從報告中消失。
報告不帶長名稱的文件:Shows the Music and LUFS column.
Music LUFS
------ ----
05 - Earth Wind and Fire - September (The Reflex Revision).mp3 -9,6
06 - Electric Light Orchestra - Last Train To London (Bootleg Extended Dance Remix).mp3 -9,1
使用長名稱的文件進行報告:Only shows the Music column and the LUFS column disappears.
Music
------
05 - Earth Wind and Fire - September (The Reflex Revision).mp3
06 - Electric Light Orchestra - Last Train To London (Bootleg Extended Dance Remix).mp3
Adele & Ellie Goulding vs. Daft Punk - The Fire Under the Sheets Something About Us (Carlos Serrano Mix...
請注意,在報告中,歌曲的長名稱並未完整顯示,僅顯示...
在最後。
腳本:
[decimal]$vLUF = -11.0
$logMatches = Select-String -Path "C:\Users\$env:username\Desktop\Logs_LUFS\*.*" -Pattern '(?<I>^ +I:) +(?<LUFS>.+)|(?<I>^Input Integrated:) +(?<LUFS>.+)' -List | Select-Object -Property FileName -ExpandProperty Matches
$results = foreach ($log in $logMatches) {
$pos = $log.Filename.IndexOf("_")
$LUFS = $log.Groups | Where-Object { $_.Name -eq "LUFS" }
[PSCustomObject]@{
Music = $log.Filename
LUFS = [decimal]$($LUFS.Value -replace " .*")
}
}
$vLUFLess = ($vLUF)+ (-0.9)
$vLUFGreat= ($vLUF)+ (-0.5)
$results | Where-Object {($_.LUFS -lt $vLUFLess) -or ($_.LUFS -gt $vLUFGreat) } | Out-File "C:\Users\$env:username\Desktop\Logs_LUFS\Music LUFS Values Report.txt"
即使歌曲名稱很長,如何使報告正確產生(兩列)?
答案1
它是這樣運作的:
建立txt檔案的路徑變數:
$files = "C:\Users\$env:username\Desktop\Logs_LUFS\Music LUFS Values Report.txt"
使用路徑變數產生txt檔案:
$results | Where-Object {($_.LUFS -lt $vLUFpsLess) -or ($_.LUFS -gt $vLUFpsGreat) } | Out-File $files