<p>I have a folder with .avi files:</p>
<pre><code>dogs
  dog1.avi
  dog2.avi
  ...
</code></pre>
<p>Each .avi file has 2 audio tracks. I want to remove the first track.</p>
<p>I can do if for one file like this:</p>
<pre><code>ffmpeg -i dog1.avi -map 0 -map -0:a:0 -c copy dog1-changed.avi
</code></pre>
<p>However I need to do it for all files.</p>
<p>I tried (after <code>cd dogs</code>):</p>
<pre><code>for f in *avi; do ffmpeg -i &quot;$f&quot; -map 0 -map -0:a:0 -c copy &quot;${f/%.avi/-changed.mkv}&quot;; done
</code></pre>
<p>However it gives</p>
<pre><code>f was unexpected at this time
</code></pre>
<p>error.</p>
<p>How do I fix it?</p>

CC BY-SA 4.0
2021-02-17T08:32:58.190Z
Are you using Bash or something else? And which version? Is the string replacement causing the issue (is it fixed if you use a literal string as output file name?) Anyway, this may not be an ffmpeg question but a scripting question. But I can't say for sure as of now.
Matt
CC BY-SA 4.0
2021-02-17T22:41:36.670Z
@Matt I'm using Windows 10 Terminal. I'll try the fixed output name
parsecer
CC BY-SA 4.0
2021-02-18T07:36:30.113Z
Windows Terminal can integrate many different shells. You probably meant the command prompt (because that's giving me the same error like you) and you're using the wrong syntax for this, to me it looks like Bash syntax and it works in Bash. You could install the Bash, and use your command as is or you rewrite it in command line syntax. Anyway, it's now obvious your question is off-topic. If you need further assistence you can ask on https://stackoverflow.com/ but please read the documentation for either the Command Line or Bash first.
Matt
<ffmpeg><audio>
ffmpeg: can't loop over files in folder to remove audio track f was unexpected at this time
parsecer
# ffmpeg: can't loop over files in folder to remove audio track f was unexpected at this time

(Asked by: username_0 on 2021-02-17)

I have a folder with .avi files:
dogs
  dog1.avi
  dog2.avi
  ...

Each .avi file has 2 audio tracks. I want to remove the first track.
I can do if for one file like this:
ffmpeg -i dog1.avi -map 0 -map -0:a:0 -c copy dog1-changed.avi

However I need to do it for all files.
I tried (after cd dogs):
for f in *avi; do ffmpeg -i "$f" -map 0 -map -0:a:0 -c copy "${f/%.avi/-changed.mkv}"; done

However it gives
f was unexpected at this time

error.
How do I fix it?

**Tags:** ffmpeg, audio

> **Comments:**
> **username_1**: Are you using Bash or something else? And which version? Is the string replacement causing the issue (is it fixed if you use a literal string as output file name?) Anyway, this may not be an ffmpeg question but a scripting question. But I can't say for sure as of now.  
> **username_0**: @username_1 I'm using Windows 10 Terminal. I'll try the fixed output name  
> **username_1**: Windows Terminal can integrate many different shells. You probably meant the command prompt (because that's giving me the same error like you) and you're using the wrong syntax for this, to me it looks like Bash syntax and it works in Bash. You could install the Bash, and use your command as is or you rewrite it in command line syntax. Anyway, it's now obvious your question is off-topic. If you need further assistence you can ask on https://stackoverflow.com/ but please read the documentation for either the Command Line or Bash first.  

---

## 0 answers

