Getting file name from %% i variable

I had a script that converts all mkvs to a folder in mp4s using ffmpeg . The downside is that he left the .mkv extension and simply added .mp4 (ex: file.mkv.mkp4 ). I know that %~n can be used to get a name without an extension, but I cannot figure it out.

Here is my original script:

 for %%i IN (*.mkv) DO (ffmpeg -y -ss 00:00:00 -threads 6 -i "%%i" -vcodec copy -f mp4 -strict experimental -acodec aac -ab 128k -ac 2 "%%i.mp4") 

Here is what I tried:

 for %%i IN (*.mkv) DO (ffmpeg -y -ss 00:00:00 -threads 6 -i "%~ni.mkv" -vcodec copy -f mp4 -strict experimental -acodec aac -ab 128k -ac 2 "%~ni.mp4") 
+4
source share
1 answer

The percentages of the loop variables should be doubled in batch scripts, so you need to use %%~ni instead of %~ni . See the Examples section in the documentation .

+3
source

All Articles