I have a bunch of mp3 files that I would like to change the extension of into m4bs, in the terminal for audiobooks. I want to convert/change the name of each indivicual mp3. I am pretty sure I can just change the file extensino and it would be work. I looked online and there are a few ways to do this, but I don't understand the steps too well. So I tried in the terminal in Ubuntu:
for i in *.mp3; do mv -- "$i" "ren-$i.m4b"; done
but that just appended .m4b to the end of each .mp3 file.
I also tried:
for file in /path/to; do mv $file $(basename -s mp3 $file)m4b ; done,
but I can´t get it to work because I am not sure what path this is. If I am in the folder itself where the mp3s are located, what is the "/path/to" supposed to refer to? I keep getting the error "mv: cannot stat '/mybook': No such file or directory"
Also I tried to convert them using ffmpeg with:
ls | grep "mp3" | awk '{printf "file |%s|\n", $0}' | sed -e "s/|/\'/g" > list.txt \
&& ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp3 \
&& ffmpeg -i output.mp3 output.m4a \
&& mv output.m4a output.m4b
but that just combined all mp3s into one file and converted it to m4b, where I would like to convert all files individual within the folder to m4b.
Is there a simple command or script I can use?
If I am in the current folder in the terminal?
Thanks