functions/public/Join-VideoFile.ps1
function Join-VideoFile { [CmdletBinding()] param ( [Parameter(Mandatory = $false)] [string] $Filter, [Parameter(Mandatory = $false)] [string] $OutputPath ) $FileList = Get-ChildItem -Path $Filter | Sort-Object -Property Name if (!$OutputPath) { $OutputPath = '{0}.concat{1}' -f $FileList[0].FullName.Substring(0, $FileList[0].FullName.Length - 1 - $FileList[0].Extension.Length), $FileList[0].Extension } $TargetFile = '{0}\ffmpeglist.txt' -f $FileList[0].Directory Set-Content -Path $TargetFile -Value '' foreach ($File in $FileList) { Add-Content -Path $TargetFile -Value ('file ''{0}''' -f $File.FullName) } ffmpeg -f concat -safe 0 -i $TargetFile -c copy $OutputPath } |