Computer Stuff and Running…

This post is going to be a bit off topic from my usual food related topics… but I am about soooo much more than food. While I haven’t actually found my path to what I want to do when I grow up, I do have a few hobbies/passions that are certainly on the top of my list of things I’d like to do the rest of my life. Cooking, obviously, but also computer programming. I still consider myself a novice at computer programming, but there is definitely an innate ability in me that allows me to be able to pick up, at least the basics of, several computer languages pretty easy. I just haven’t created a large program or even programmed with others. I’ve just programmed stuff for class and an occasional program for myself, so as for a career, I’ve got a lot more to learn.

Anyway, tonight, and I’m not sure what made me do this, I googled the phrase ‘how to become a runner’. I found a couple of good sites for just what to do to go from being a walker to a runner. I stumbled upon Life Learning Today, eHow, and Princess Nebraska. I really liked the humor in Princess Nebraska’s post. She also led me to The Couch-to-5K Running Plan, which then led me to get the podcasts that go with the couch-to-5k running plan. The podcasts are .m4a files. Which brings us to the computer programming part…

I don’t own an iPod, so my phone/mp3 player doesn’t know what to do with a .m4a file. I run Fedora, which is a Linux operating system… so I googled ‘linux m4a’. Programming is a lot like cooking. Once you understand the basic method, you can look at many recipes and pick out the parts that sound like they’d taste good to you. I do it all the time. The same is true with programming, once you understand the basic syntax of a programming language, you can look at other people’s code and then pick out the parts that will do what you want. The two sites that led me to the script that I used, where LinuxQuestions.org and oddly eHow.

I downloaded the nine podcasts and then converted them to mp3s and then loaded them onto my phone/mp3 player. It was a bit of trial and error, but I got it to work. And I have to put a little woohoo out there for myself. This was actually quite an accomplishment for me, normally I would call my ‘taste-tester’ at work and get his help. I did this solo! Yea me!

If you are a linux user and would like to know the script I used, I will post it below. You will need to have both lame and faad2 installed. For Fedora or RedHat, you would just type (after becoming root):

    yum install lame faad2

After you have installed those, you can get out of root.

Then create a file, I named mine m4a-to-mp3, and copy this into that file.


    #!/bin/bash
    #
    ## you need lame and faad2 installed
    # Dump m4a to mp3

    #step one, convert .m4a to .wav
    for i in *.m4a
    do faad “$i”
    done

    #step two, convert .wav to .mp3
    for i in *.wav
    do
    lame -h -b 192 “$i” “$i.mp3”
    done

    #step three, clean up… change .wav.mp3 files to .mp3 files
    for i in *.mp3
    do
    x=`echo “$i”|sed -e ‘s/wav.mp3/mp3/’`
    mv “$i” “$x”
    done

    #step four, organize… put files into respective directories
    for i in *.mp3
    do
    mv “$i” mp3/
    done

    for i in *.wav
    do
    mv “$i” wav/
    done

    for i in *.m4a
    do
    mv “$i” m4a/
    done

Then you need to make that file executable…

    chmod u+x m4a-to-mp3

and you need to make three directories, in order for step 4 to work.

    mkdir mp3/ m4a/ wav/

Then after you have downloaded all of the .m4a files that you want to convert, simply run the script…

    ./m4a-to-mp3

You will see the files start to be processed, after a few minutes you will have converted files that are neatly organized into their respective directories.

I’m sure that someone out there is able to make the script in one line or something cool like that, but I aim for readability and maintenance when I code.

So, I’m hoping to start the couch-to-5k tomorrow, but it is supposed to rain. I’ll check the weather in the morning and we’ll see how it goes.
~nic

Update
My ‘taste-tester’ being the awesome one that he is, created a one-line script, feel free to use his if you’d like… his also doesn’t have the large .wav files at the end, nor do you need to make directories first… 🙂

    mkdir mp3; for x in *.m4a; do y=`basename “$x” .m4a`.mp3; faad -o – “$x” | lame -h -b 192 – mp3/”$y”; done

~nic 😀

Advertisements

5 thoughts on “Computer Stuff and Running…

  1. Pingback: Week 1 Day 1 (Couch to 5K)… « The Auspicious Squirrel

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s