<p>The problem is that the code you adapted was intended for <code>.avi</code> files, not <code>.mp4</code>, so you are trying to replace a string that does not exist.</p>
<p>The following would work:</p>
<pre class="lang-bash prettyprint-override"><code>for f in *.mp4; do
  ffmpeg -i &quot;$f&quot; -an -c:v copy &quot;${f/%.mp4/-noaudio.mp4}&quot;
done
</code></pre>

CC BY-SA 4.0
2022-05-04T15:33:22.267Z
2022-05-04T15:33:22.267Z
slhck
<p>I am a novice coder using Terminal on MAC that has installed FFMPEG and attempting to edit an entire directory.</p>
<p>My goal is <strong>to remove all of the audio from all of the videos and output or overwrite the existing files</strong>. I was successful in writing a line of code that inputted and outputted ONE file accurately, however, when I attempted to adapt the code others have posted across the web, the terminal would time-out or error. Attached are a couple of screenshots of what happens for two of the scenarios I thought was sure to work:</p>
<p>Screenshot one:
<a href="https://i.sstatic.net/HCDJ0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HCDJ0.png" alt="enter image description here" /></a></p>
<p>Screenshot two:
<a href="https://i.sstatic.net/niC1Y.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/niC1Y.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-05-04T15:33:43.913Z
Next time posting code, please copy-paste the code into the editor. Screenshots are hard to read and copy from. Thanks!
slhck
<ffmpeg>
FFMPEG: How to remove audio from entire directory
Refusionist
# FFMPEG: How to remove audio from entire directory

(Asked by: username_0 on 2022-05-03)

I am a novice coder using Terminal on MAC that has installed FFMPEG and attempting to edit an entire directory.

My goal is **to remove all of the audio from all of the videos and output or overwrite the existing files**. I was successful in writing a line of code that inputted and outputted ONE file accurately, however, when I attempted to adapt the code others have posted across the web, the terminal would time-out or error. Attached are a couple of screenshots of what happens for two of the scenarios I thought was sure to work:

Screenshot one:
[![enter image description here](https://i.sstatic.net/HCDJ0.png)](https://i.sstatic.net/HCDJ0.png)

Screenshot two:
[![enter image description here](https://i.sstatic.net/niC1Y.png)](https://i.sstatic.net/niC1Y.png)

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Next time posting code, please copy-paste the code into the editor. Screenshots are hard to read and copy from. Thanks!  

---

## 1 answers

### Answer by username_1 on 2022-05-04. Score: 1

The problem is that the code you adapted was intended for .avi files, not .mp4, so you are trying to replace a string that does not exist.
The following would work:
for f in *.mp4; do
  ffmpeg -i "$f" -an -c:v copy "${f/%.mp4/-noaudio.mp4}"
done


---

