<p>I think you can achieve what you need with my ffmpeg Windows front-end, where you can easily select output destination folder.</p>

<p><a href="https://sourceforge.net/projects/ffmpeg-batch" rel="nofollow noreferrer">https://sourceforge.net/projects/ffmpeg-batch</a></p>

<p>It adds to ffmpeg a window fashion interface, progress bars and time remaining info, features I always missed when using ffmpeg.</p>

CC BY-SA 3.0
2018-04-25T18:58:32.907Z
Please make sure to clearly indicate if an answer refers to a software or product that you are affiliated with.  I have altered the answer to include the needed information.
AJ Henderson
CC BY-SA 4.0
2019-04-11T11:05:36.697Z
Yes indeed, thanks for the clarification, just trying to make people's life easier.
Eibel
CC BY-SA 3.0
2018-04-25T09:39:40.213Z
2018-04-25T18:57:35.580Z
2018-04-25T18:57:35.580Z
Eibel
<blockquote>
  <p>I'm trying to batch encode 45 video files, and copy the encoded files into an existing subfolder called "encode"</p>
</blockquote>

<p>Try this: <a href="https://github.com/alessandro893/ffmpeg-batch-remux" rel="nofollow noreferrer">https://github.com/alessandro893/ffmpeg-batch-remux</a></p>

CC BY-SA 4.0
2018-08-06T23:48:38.087Z
Could you provide a little more detail on how to use the tool you linked to? Most people come here looking for more in depth answer than just a link.
Michael Liebman
CC BY-SA 4.0
2018-08-06T08:42:19.383Z
2018-08-06T08:42:19.383Z
Alexander Kolesnikov
<p>To convert a file within the same format without the extension saved into file name in batch mode just add ~n to the final input, like so:</p>

<pre><code>for %f in (*.mkv) do ffmpeg -i %f &lt;additional options&gt; %~nf.mp4
</code></pre>

<p>If one needs to reformat the codec and wishes to keep the same title and save in the same extension it must be saved into another folder. Start the ffmpeg command from the location of the original files. Navigate to that different folder and copy the entire location from the address bar and paste it exactly as is at the beginning of the output name. For this there must be " " around the whole output address. Replace everything within () with your address, and then remove the ().</p>

<pre><code>for %a in (*.mp4) do ffmpeg -i "%a" &lt;additional options&gt; "(F:\VIDEO\New)\%~na.mp4"
</code></pre>

CC BY-SA 4.0
2019-12-09T02:43:39.623Z
2019-12-09T18:26:27.153Z
2019-12-09T18:26:27.153Z
C.J.
<p>The accepted answer in the question you're referring to uses additional unnecessary processes, legacy code, and doesn't prevent globbing or word splitting.</p>

<p>See the <a href="https://stackoverflow.com/a/33766147/1109017">second answer</a> which is shorter, simpler, and more efficient:</p>

<pre><code>for f in *.mp4; do ffmpeg -i "$f" &lt;additional options&gt; "encoded/${f%.*}.mp4"; done
</code></pre>

<p>Secondly, don't use fancy quotes which will cause errors, so instead of <code>“$varible”</code> use <code>"$variable"</code>.</p>

CC BY-SA 3.0
2017-01-21T17:20:16.973Z
Returns `f was unexpected at this time`. I feel like I'm missing something.
user3643
CC BY-SA 3.0
2017-01-21T18:34:36.030Z
I had to use `for %f in (*.mp4); do ffmepg -i %f <additional options> %f.mp3`. I got the batch to run correctly, but the extension is now duplicated. My files look like `file.mp4.mp3`. I'll figure it out soon, I'm sure.
user3643
CC BY-SA 3.0
2017-01-21T20:15:08.800Z
Acutally, I couldn't figure it out. Perhaps you can help: http://video.stackexchange.com/questions/20474/how-to-change-output-filename-in-ffmpeg-batch
user3643
CC BY-SA 3.0
2017-01-23T06:15:12.343Z
@fredsbend Are you using Windows? My example is Bash shell (for Linux users).
llogan
CC BY-SA 3.0
2017-01-23T07:57:04.283Z
@LordNeckbeard Yes, I'm on Windows 10.
user3643
CC BY-SA 3.0
2016-11-16T21:42:30.790Z
2016-11-16T21:42:30.790Z
2017-05-23T12:40:36.170Z
llogan
<p>I'm trying to batch encode 45 video files, and copy the encoded files into an existing subfolder called "encode"</p>

<p>I've used the suggested code from this question (<a href="https://stackoverflow.com/questions/5784661/how-do-you-convert-an-entire-directory-with-ffmpeg">https://stackoverflow.com/questions/5784661/how-do-you-convert-an-entire-directory-with-ffmpeg</a>) But, I don't know how to capture the original file names (with spaces and punctuation) and use that as the new file name in the new directory.</p>

<p>Here's the code I'm using so far:</p>

<p><code>
for i in *.mp4;
  do name=`echo "${i%.*}"`;
  echo $name;
  ffmpeg -i “$i” -vf "scale='if(gt(a*sar,16/9),640,-1)':'if(gt(a*sar,16/9),-1,360)',pad=640:360:(ow-iw)/2:(oh-ih)/2,setsar=1" -vcodec libx264 -b:v 1600k -bufsize:v 1600k -r 30000/1001 “encoded/$name.mp4”
done
</code> 
It's giving me an "invalid argument" error message when I run it - probably because I haven't specified the names correctly(?)</p>

<p>The ffmpeg code that I'm using does work (I can encode individual file) but I haven't figured out how to batch encode the entire directory.</p>

<p>If anyone can let me know what I'm doing wrong, I would love to know!</p>

<p>Thank you!</p>

CC BY-SA 3.0
2017-01-23T07:40:41.707Z
For users looking for a Windows solution see [How to change output filename in ffmpeg batch?](http://video.stackexchange.com/a/20475/1760)
llogan
<ffmpeg>
Batch conversion into a new folder with ffmpeg
d13
# Batch conversion into a new folder with ffmpeg

(Asked by: username_0 on 2016-11-16)

I'm trying to batch encode 45 video files, and copy the encoded files into an existing subfolder called "encode"

I've used the suggested code from this question (<https://stackoverflow.com/questions/5784661/how-do-you-convert-an-entire-directory-with-ffmpeg>) But, I don't know how to capture the original file names (with spaces and punctuation) and use that as the new file name in the new directory.

Here's the code I'm using so far:

`for i in *.mp4;
do name=`echo "${i%.*}"`;
echo $name;
ffmpeg -i “$i” -vf "scale='if(gt(a*sar,16/9),640,-1)':'if(gt(a*sar,16/9),-1,360)',pad=640:360:(ow-iw)/2:(oh-ih)/2,setsar=1" -vcodec libx264 -b:v 1600k -bufsize:v 1600k -r 30000/1001 “encoded/$name.mp4”
done`
It's giving me an "invalid argument" error message when I run it - probably because I haven't specified the names correctly(?)

The ffmpeg code that I'm using does work (I can encode individual file) but I haven't figured out how to batch encode the entire directory.

If anyone can let me know what I'm doing wrong, I would love to know!

Thank you!

**Tags:** ffmpeg

> **Comments:**
> **username_1**: For users looking for a Windows solution see [How to change output filename in ffmpeg batch?](http://video.stackexchange.com/a/20475/1760)  

---

## 4 answers

### Answer by username_1 on 2016-11-16. Score: 6 | Accepted answer

The accepted answer in the question you're referring to uses additional unnecessary processes, legacy code, and doesn't prevent globbing or word splitting.
See the second answer which is shorter, simpler, and more efficient:
for f in *.mp4; do ffmpeg -i "$f"  "encoded/${f%.*}.mp4"; done

Secondly, don't use fancy quotes which will cause errors, so instead of “$varible” use "$variable".

> **Comments:**
> **username_7**: Returns `f was unexpected at this time`. I feel like I'm missing something.  
> **username_7**: I had to use `for %f in (*.mp4); do ffmepg -i %f <additional options> %f.mp3`. I got the batch to run correctly, but the extension is now duplicated. My files look like `file.mp4.mp3`. I'll figure it out soon, I'm sure.  
> **username_7**: Acutally, I couldn't figure it out. Perhaps you can help: http://video.stackexchange.com/questions/20474/how-to-change-output-filename-in-ffmpeg-batch  
> **username_1**: @fredsbend Are you using Windows? My example is Bash shell (for Linux users).  
> **username_7**: @LordNeckbeard Yes, I'm on Windows 10.  

---

### Answer by username_2 on 2018-04-25. Score: 2

I think you can achieve what you need with my ffmpeg Windows front-end, where you can easily select output destination folder.

<https://sourceforge.net/projects/ffmpeg-batch>

It adds to ffmpeg a window fashion interface, progress bars and time remaining info, features I always missed when using ffmpeg.

> **Comments:**
> **username_3**: Please make sure to clearly indicate if an answer refers to a software or product that you are affiliated with.  I have altered the answer to include the needed information.  
> **username_2**: Yes indeed, thanks for the clarification, just trying to make people's life easier.  

---

### Answer by username_4 on 2018-08-06. Score: 0

> I'm trying to batch encode 45 video files, and copy the encoded files into an existing subfolder called "encode"

Try this: <https://github.com/alessandro893/ffmpeg-batch-remux>

> **Comments:**
> **username_5**: Could you provide a little more detail on how to use the tool you linked to? Most people come here looking for more in depth answer than just a link.  

---

### Answer by username_6 on 2019-12-09. Score: 0

To convert a file within the same format without the extension saved into file name in batch mode just add ~n to the final input, like so:
for %f in (*.mkv) do ffmpeg -i %f  %~nf.mp4

If one needs to reformat the codec and wishes to keep the same title and save in the same extension it must be saved into another folder. Start the ffmpeg command from the location of the original files. Navigate to that different folder and copy the entire location from the address bar and paste it exactly as is at the beginning of the output name. For this there must be " " around the whole output address. Replace everything within () with your address, and then remove the ().
for %a in (*.mp4) do ffmpeg -i "%a"  "(F:\VIDEO\New)\%~na.mp4"


---

