batch file – Variables in ffmpeg
This is a batch scripting ‘gotcha’. Due to the way cmd.exe expands variables, if you use SET with parenthesis blocks (such as FOR, IF etc) you need to
(1) have this line somewhere in the batch script before the start of the block:
setlocal enabledelayedexpansion
(2) AND ALSO any variable that you SET in the block and wish to use in that block needs to use exclamation marks/points and not percent signs
like this
@echo off
setlocal enabledelayedexpansion
for /r %%F in (*.ts) do (
echo %%~nxF
set /P moviename=NEW VIDEO NAME:
"c:\program files\ffmpeg" -y -i "%%F" -map 0 -c copy -metadata title="!moviename!" "%%~pnF.mp4" 2>> output.log
)
Read more here: Source link
