I want the following loop to go through m4a files AND webm files. At the moment I use two diffrent loops, the other one just replaces all the m4a from this loop. Also the fi
Try the following:
for i in *.m4a *.webm; do
echo "Converting file $converted / $numfiles : $i"
ffmpeg -hide_banner -loglevel fatal -i "$i" "./mp3/${i%.*}.mp3"
mv "$i" ./done
converted=$((converted + 1))
done
You can use for with multiple patterns (globs), as demonstrated here: *.m4a *.webm will expand to a single list of tokens that for iterates over.
shopt -s nullglob before the loop so that it isn't entered with the unexpanded patterns in the event that there are no matching files.${i%.*}.mp3 uses parameter expansion - specifically, % for shortest-suffix removal - to strip any existing extension from the filename, and then appends .mp3.
Note that the techniques above use patterns, not regular expressions. While distantly related, there are fundamental differences; patterns are simpler, but much more limited; see pattern matching.
P.S.: You can simplify converted=$((converted + 1)) to (( ++converted )).