Hero Inc.

where heroes are an everyday occurrence

Dec-10-2011

Amazon Music Downloader and Shell Script

Well I’ve been away from this site for a long time and this is not exactly my planned first post back, but I created something I found useful today so I decided to share it.

Recently I’ve been purchasing my music from Amazon. Running a linux environment at home, downloading music from the big names can be quite painful. However, Amazon has done a great job to address this. It is fairly simple but I wanted to go just a little farther with the help of clamz and a simple script. clamz is a downloader program for the Amazon music store. It works great, but I’m always forgetful when it comes to what actually to place in the command when trying to run it.

Here’s my shell script. It’s pretty basic as my shell script skills are not well developed, but hey, it works.

#!/bin/sh
# Date:       2011-12-10
# Author:     Benjamin Trice
# Reference:  http://heroinc.org/?p=2428

echo "************************************";
echo "* Start Amazon Music Download v1.0 *";
echo "************************************";

echo "What directory should be used to store the downloaded music files?"
read MUSICDIR
echo "";

if [ -d "$MUSICDIR" ]; then echo "Directory exists."
else mkdir $MUSICDIR;
echo $MUSICDIR " directory created.";
fi

echo "What directory contains the .amz file provided by Amazon?"
read AMAZONDIR
echo "";

clamz -d $MUSICDIR $AMAZONDIR/*.amz

echo "";
echo "END SCRIPT";

As you can see, all it does is utilize the clamz script with some additional friendly user input to download the files. Like I said, I’m lazy and forgetful at times and this just makes it easier for me. For those not knowing how to use the script, follow the following steps:

  1. Download and install clamz via the link at the top of this page. Follow its instructions for installing it. Your current linux distribution might already package it so try your repository if you are not comfortable with the clamz instructions.
  2. Save my shell script with a file name of “startAmazon”. You can change the name if you want.
  3. From the terminal window type the following command:
    chmod a+x startAmazon

    If you changed the file name, then the command will need to be changed as well. This command will make the file executable.

  4. Perform the following command in order to be able to call the script from any directory.
    sudo cp startAmazon /usr/bin/

That’s it. Now you can run “startAmazon” from any directory when you are ready to download your music quickly and easily. I doubt I’ll make any updates to this script unless there are changes to clamz. Enjoy!

Posted under Linux

Add A Comment

If you would like to track when new comments have been made, subscribe to the Comments Feed.