"For" command help required

I have a ffmpeg script like this:

for %%x in (*.mp4) do ffmpeg -i "%%x" -i "%%x".srt -vcodec copy -acodec copy -scodec copy -map 0:0 -map 0:1 -map 1:0 -y "%%x".mkv

however the problem with the current script is that it includes the full filename+extension, that hinders the script from working.

for example I would require "trailer.srt" however by using for the way I use it I will get "trailer.mp4.srt"

After Windows expands the variable completely, the code would look like this:

ffmpeg -i trailer.mp4 -i trailer.mp4.srt -vcodec copy -acodec copy -scodec copy -map 0:0 -map 0:1 -map 1:0 -y trailer.mp4.mkv

I want it to be this:

ffmpeg -i trailer.mp4 -i trailer.srt -vcodec copy -acodec copy -scodec copy -map 0:0 -map 0:1 -map 1:0 -y trailer.mp4

[/CODE]

---------- Post updated at 08:13 PM ---------- Previous update was at 05:21 PM ----------

Guess I fixed it myself...

the magical thing to use here is

 %%~nx

=>

ffmpeg -i %%x -i %%~nx -vcodec copy -acodec copy -scodec copy -map 0:0 -map 0:1 -map 1:0 -y %%~nx.mp4

as stated here windows - How do I hide file extensions in a command prompt /dir output? - Super User

Thanks for posting the solution you found. :b: