Grok3に聞いた

@echo off
cd "ターゲットフォルダのパス"
setlocal enabledelayedexpansion

set "output=output.mp4"
set "fileList=temp_list.txt"

:: 既存のリストファイルを削除
if exist "%fileList%" del "%fileList%"

:: フォルダ内の全ファイルをリストに追加
for %%a in (*.*) do (
echo file '%%a' >> "%fileList%"
)

:: FFmpegで全ファイルを一度に結合
"ffmpeg.exeのパス" -f concat -safe 0 -i "%fileList%" -c:v copy -c:a aac -map 0:v:0 -map 0:a:0 "%output%"

:: 元ファイルを削除(output.mp4以外)
for %%f in (*.*) do (
if not "%%f"=="%output%" if not "%%f"=="%fileList%" (
del "%%f"
)
)

:: 一時リストファイルを削除
del "%fileList%"

echo 結合が完了しました。
pause