Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 2460  / 3 Years ago, thu, june 17, 2021, 4:00:53

I have a bunch of files which need to be converted from .mp4 to .mpeg.one. A friend of mine had suggested me this simple script. However it doesn't work because filenames contain blank spaces.



Here is the script:



for f in $(ls *.mp4); do ffmpeg -i "$f".mp4 "$f".mprg; done

More From » bash

 Answers
5

You don't need to use ls in this case. As a general rule, always try to use shell builtins and glob features instead of relying on external programs (e.g. ls) that can introduce problems with ugly workarounds.



Also, you shouldn't 'manually' append the extension to the input file name (the one you give to -i) and you should strip the extension on the output file.



So the command should be:



for f in *.mp4; do ffmpeg -i "$f" "${f%.mp4}".mprg; done

[#32861] Friday, June 18, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
diffeah

Total Points: 78
Total Questions: 130
Total Answers: 98

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;