I'm looking for a way to automate file conversions. I'm using an Ubuntu virtual machine through which I'm accessing a Windows installation. The normal syntax should be:
ffmpeg -i file.mp4 file.mp3
So this is what I'm trying to do:
ls | while read i; do echo ffmpeg -i \"$i\" \"${i/mp4/mp3}\"; done
As you can see I added "echo" to see the generated command first and this is what I get:
ffmpeg -i "Accepting Amendments.mp4" "Accepting Amendments.mp3"
As you can see, the file names may have spaces, so I'm trying to escape them. However this command doesn't work when I remove the "echo". What happens is only some conversions are made and I'm getting error messages with split file names such as "ccepting Amendments.mp4" for instance. So basically the first ffmpeg command runs fine, then the second one fails, and so on.
I've noticed that when I run an ls
command, I'm getting filenames with single quotes, but when I create a file myself, there are no quotes.
$ls
'Accepting Amendments.mp4'
$touch test
$ls
'Accepting Amendments.mp4'
test
Could that be the issue?