Skip to content

Instantly share code, notes, and snippets.

@JamieMagee
Created March 6, 2024 22:17
Show Gist options
  • Save JamieMagee/7eb6d799cdd0ff944e5fa0bbc011da2e to your computer and use it in GitHub Desktop.
Save JamieMagee/7eb6d799cdd0ff944e5fa0bbc011da2e to your computer and use it in GitHub Desktop.
$directory = "E:\DCIM\100GOPRO"
$rootFiles = Get-ChildItem -Path $directory -Filter "GOPR*.MP4" | Sort-Object
$suffixes = $rootFiles | ForEach-Object { $_.BaseName.Substring($_.BaseName.Length - 4) }
$groups = $suffixes | ForEach-Object {
$suffix = $_
$group = Get-ChildItem -Path $directory -Filter "*$suffix*.MP4" | Sort-Object
[PSCustomObject]@{
Suffix = $suffix
Group = $group
}
}
foreach ($group in $groups) {
$inputFileList = New-TemporaryFile
$group.Group | ForEach-Object { "file '$($_.FullName)'" } | Out-File -FilePath $inputFileList
# Create a temporary file based on the date and time of the video
$outputFileName = $group.Group[0].CreationTime.ToString("yyyyMMdd_HHmmss") + ".mp4"
$outputFile = Join-Path -Path $env:TEMP -ChildPath $outputFileName
ffmpeg -hwaccel auto -f concat -safe 0 -i $inputFileList -c copy -y $outputFile -progress -
Remove-Item -Path $inputFileList
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment