I've found some examples of doing this in similar situations, but this is the only shell-script I've written that does anything besides run commands verbatim, so I am struggling to apply the examples to my own situation and need some hand-holding <3
I'm just trying to batch rip audio from MP4s. This script works:
for f in *.mp4;
ffmpeg -i "$f" -f mp3 -ab 192000 -vn "mp3s/$f.mp3"
done
But the files all end with .mp4.mp3. How can I get rid of the mp4 part?
Following command to change file extension for all files under the current directory.
If you're using bash
will give the filename without the
.mp4
extension.Try using it like this:
... and don't forget the
do
keyword as in the example given.Explanation
The bash Manual(
man bash
) states:This is just one of many string manipulations you can perform on shell variables. They all go by the name of Parameter Expansion.
That's as well the section label given in the bash manual. Thus
man bash
/paramter exp should bring you there fast. `