This a follow up from my post yesterday on using PowerShell and FFMPEG to trim many MP3 files at once. The second part of my task was to merge those MP3 files into one big MP3 file.
The script is below.
Important Note: For a reason I'm not clear on I had to run PowerShell as Administrator for FFMPEG to successfully create the merged MP3.
$ffmpeg_exe = "D:\ffmpeg\bin\ffmpeg.exe"
$fromitems = (Get-ChildItem $FromFolder -Filter "*.mp3" -recurse -File)
$fromnames = @()
foreach ($fromitem in $fromitems)
$basename = $fromitem.Name
Write-Verbose "Item [$count]: $basename"
$from_fullname = $fromitem.FullName
$fromnames += $from_fullname
$fromnames_all = [string]::join('|', $fromnames )
if (Test-Path $ToFile)
$cmdline = "$ffmpeg_exe -i `"concat:$fromnames_all`" -acodec copy `"$ToFile`" "
Write-Verbose "`t CMD: $cmdline"
invoke-expression -command $cmdline
Folder_MP3_Merge -FromFolder "D:\mymp3files" -ToFile "D:\single.mp3" -Verbose