脚本目的:
读取音频文件并创建包含每首歌曲名称和每首歌曲的 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