Friday, February 5, 2016

Everything I learned in the past 24 hours about linux 1454703438

Convert all m4a files into mp3's in a directory:

IFS=$(echo -en "\n\b");for i in *.m4a; do name=`echo $i | cut -d'.' -f1`; echo $name; ffmpeg -i $i $name.mp3;   done


@nayafia at medium.com has been blogging about open source infrastructure projects and the posts so far have been interesting.

I added these to my .bashrc:
alias volumedown='amixer -D pulse sset Master 5%-'
alias volumeup='amixer -D pulse sset Master 5%+'

For reducing and increasing the volume.

1 comment:

Unknown said...

Cleaned it up for you:

for i in $(ls|grep .m4a$); do echo $i|sed 's/.m4a$//'; ffmpeg -i $i $i.mp3; done

This version does not need the IFS setting since the for loop uses process substitution. I also noticed that $name would not display properly in yours if the name includes multiple periods, and for some reason you used both $() and `` for process substitution.

Cleaner, more portable, and it has the edge in golf:

for i in $(ls|grep .m4a$); do echo $i|sed 's/.m4a$//'; ffmpeg -i $i $i.mp3; done

vs

IFS=$(echo -en "\n\b");for i in *.m4a; do name=`echo $i | cut -d'.' -f1`; echo $name; echo ffmpeg -i $i $name.mp3; done