<p>With Gyan's help I was able to get it to work.
<code>%~n1.mp4</code> will get the filename and substitute the file extension with mp4.
To get the correct path as well, I added <code>%~p1</code>.
So all in all I now use <code>%~p1%~n1.mp4</code> and it works exactly as intended.</p>

CC BY-SA 4.0
2019-11-05T20:09:38.027Z
2019-11-05T20:09:38.027Z
MikeKnight
<p>I've been searching around for this for some time but can't find a working solution.
I found this <a href="https://video.stackexchange.com/questions/20474/how-to-change-output-filename-in-ffmpeg-batch">question</a>, which is close, but not exactly what I need.</p>

<p>I'm windows and ffmpeg to convert movs to mp4.
What I would like to have is a cmd file on my desktop on which I can drop my mov from any folder and the cmd file will create an mp4 with the same name in the same folder as the original mov, except the extension should be mp4. </p>

<p>My cmd file looks like this:</p>

<p><code>@echo off</code>
<code>ffmpeg -i %1 -s 1920x1080 -c:v libx264 -preset slow -bf 2 -crf 18 -pix_fmt yuv420p -movflags faststart -r 25 -profile:v baseline -level 3.0 -c:a aac -b:a 192k %1.mp4</code>
<code>pause</code></p>

<p>This creates the file Test.mov.mp4.
I tried 
<code>-f mp4 "%1~nf.mp4"</code>
instead of <code>%1.mp4</code> but this outputs Test.mov~nf.mp4.</p>

CC BY-SA 4.0
2019-11-01T06:55:45.473Z
Use  `%~n1.mp4`.
Gyan
CC BY-SA 4.0
2019-11-01T21:19:38.807Z
Ah thank you! Now I sort of get it. Although I had to add the path as well, so now I have `%~p1%~n1.mp4` and it works!
MikeKnight
CC BY-SA 4.0
2019-11-04T19:10:45.613Z
You can add that as your answer.
llogan
<ffmpeg><mp4><windows>
How do I change output file format in ffmpeg batch, when using drag and drop?
MikeKnight
# How do I change output file format in ffmpeg batch, when using drag and drop?

(Asked by: username_0 on 2019-11-01)

I've been searching around for this for some time but can't find a working solution.
I found this [question](https://video.stackexchange.com/questions/20474/how-to-change-output-filename-in-ffmpeg-batch), which is close, but not exactly what I need.

I'm windows and ffmpeg to convert movs to mp4.
What I would like to have is a cmd file on my desktop on which I can drop my mov from any folder and the cmd file will create an mp4 with the same name in the same folder as the original mov, except the extension should be mp4.

My cmd file looks like this:

`@echo off`
`ffmpeg -i %1 -s 1920x1080 -c:v libx264 -preset slow -bf 2 -crf 18 -pix_fmt yuv420p -movflags faststart -r 25 -profile:v baseline -level 3.0 -c:a aac -b:a 192k %1.mp4`
`pause`

This creates the file Test.mov.mp4.
I tried
`-f mp4 "%1~nf.mp4"`
instead of `%1.mp4` but this outputs Test.mov~nf.mp4.

**Tags:** ffmpeg, mp4, windows

> **Comments:**
> **username_1**: Use  `%~n1.mp4`.  
> **username_0**: Ah thank you! Now I sort of get it. Although I had to add the path as well, so now I have `%~p1%~n1.mp4` and it works!  
> **username_2**: You can add that as your answer.  

---

## 1 answers

### Answer by username_0 on 2019-11-05. Score: 1

With username_1's help I was able to get it to work.
`%~n1.mp4` will get the filename and substitute the file extension with mp4.
To get the correct path as well, I added `%~p1`.
So all in all I now use `%~p1%~n1.mp4` and it works exactly as intended.


---

