-2
#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
for f in *.webm; do
  uuid=$(uuidgen)
  ffmpeg -i $f -vcodec libx264 -preset slow -crf 18 -vf scale=720:-2 ${uuid}.mp4
done

./convert.sh: line 3: syntax error near unexpected token $'do\r'' '/convert.sh: line 3:for f in *.webm; do

I have many .webm files in a folder and I want to convert them all using ffmpeg!

The problem was about Windows. I was using Bash on Windows and it gave me issues.

Cœur
  • 37,241
  • 25
  • 195
  • 267
nickbm94
  • 1
  • 1

1 Answers1

-3

Try:

...
for f in `ls *.webm`; do
...
done
alnet
  • 1,093
  • 1
  • 12
  • 24
  • 2
    `for f in *.webm` is _exactly_ how to do it. What you have suggested is a complete anti-pattern. – Tom Fenech Aug 03 '17 at 09:59
  • +1 @TomFenech you've mentioned somewhere that `[[ $(...) ]]` is also an anti pattern. Could you please point us a documentation or some-other reference with further details on bash anti-patterns. – Anubis Aug 03 '17 at 10:54
  • 1
    https://stackoverflow.com/q/4708549/2088135 explains why backticks are deprecated. `[[ $() ]]` isn't necessarily wrong but often comes from misunderstanding of how tests work in the shell. Search "shell anti-patterns" and you will find plenty of information. Also the [bash tag wiki](https://stackoverflow.com/tags/bash/info) has a lot of useful links. – Tom Fenech Aug 03 '17 at 11:02