0

I'm trying to do a basic batch script for create video titles in movie files (*.ts) but it doesn't work when adding SET variable.

@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 ) 

1 Answer 1

0

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 ) 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.