The task could be done with:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "BaseSourceFolder=C:\Temp\Source"
set "BaseTargetFolder=C:\Temp\Target"
for /R "%BaseSourceFolder%" %%I in (*.vob) do (
set "FullSourceFileName=%%I"
set "TargetFolder=%%~dpI"
set "TargetFileName=%%~nI"
setlocal EnableDelayedExpansion
set "TargetFolder=!TargetFolder:%BaseSourceFolder%=%BaseTargetFolder%!"
if not exist "!TargetFolder!" md "!TargetFolder!"
if exist "!TargetFolder!" "ffmpeg.exe" -i "!FullSourceFileName!" -vf yadif=1 -c:v h264_nvenc "!TargetFolder!!TargetFileName!.mp4"
endlocal
)
endlocal
The folder paths of BaseSourceFolder
and BaseTargetFolder
must be defined in third and fourth line.
BaseSourceFolder
cannot contain character =
as otherwise the code would not work.
The two paths can be identical although in this case it would be more efficient to use a batch file with just one command line.
The executable file ffmpeg.exe
should be specified in batch file with full path for more efficiency as in this case the Windows command processor cmd.exe
would not need to search on each VOB file for the executable in current directory and if not found in one directory after the other listed in environment variable PATH
until found.
To understand the commands used and how they work, open a command prompt window, execute there the following commands, and read the displayed help pages for each command, entirely and carefully.
echo /?
endlocal /?
for /?
if /?
md /?
set /?
setlocal /?
See also this answer for more details about the commands SETLOCAL and ENDLOCAL.