myMPX
Advertisement


Go Back MyMPx.org > MyMPx.org Forum > Support and How To

HowTo: Linux music management
Reply
Post New Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old 2nd Feb 2007, 9:05 am
New Member
 
Join Date: Feb 2007
Posts: 7
Default HowTo: Linux music management


Here are some scripts that I use for maintaining music on my linux
(kubuntu,ubuntu edgy) box.

First, I created up a directory off of my home directory called SONGS. I
use the KAudioCreator to rip CDs to the SONGS directory. Here is
KAudioCreator's file location spec:

~/SONGS/%{albumartist}/%{albumtitle}/%{number} - %{title}.%{extension}

I set the encoder to FLAC (run 'apt-get install flac' as root). This is
because FLAC is lossless.

After ripping the music, I convert the songs from FLAC to OGG format. It
is the OGG files that I am going to place on the MP3 player since they
are much smaller than FLAC files and the encoding is not proprietary
(you could, of course, use WAV for lossless encoding and MP3 or WMA as
the compressed format, assuming you have the codecs).

To convert to OGG format, I use the following script, named flac2ogg:

for s in "$@"
do
chmod 644 "$s"
name=`basename "$s" .flac`
echo converting "$s" to OGG
flac -s -f -d -c "$s" | sox -t wav - "$name".ogg
done

As you can see, you will need to install sox (apt-get install sox). Here
is an example use of the script:

flac2ogg *.flac

...which converts every flac file in the current director to ogg format
(the original flac files are kept).

Next, I move the ogg files to mp3 player (which is viewed by Linux as
a USB mass storage device). I use the following script to preserve the
directory hierarchy. I named the script comp2player:

location=media/usbdisk
where=`pwd`
name=`artist "$where"`
mkdir -p $location/SONGS/"$name"
for s in "$@"
do
cp "$s" $location/SONGS/"$name"/"$s"
done

You may need to change the location variable to wherever your system
mounts your player. Here is an example use of the script...

comp2player *.ogg

...which copies every ogg file in the current directory to the mp3
player. If the location of ogg files is...

~/SONGS/Bob\ Seger/Greatest\ Hits/

...the ogg files will be located at...

/SONGS/Bob\ Seger/Greatest\ Hits/

...on the mp3 player. The artist command referenced by the script
strips off the front part of the PATH up to and including the SONGS
directory. You could probably use awk to do this, but it was faster for
me to write a C program than to figure out awk:

#include <stdio>
#include <stdlib>
#include <string>

static char *strip(char *);

int
main(int argc,char **argv)
{
if (argc != 2)
{
fprintf(stderr,"usage: artist <dir>\n");
exit(-1);
}

printf(strip(argv[1]));

return 0;
}

static char *
strip(char *location)
{
char *s;

s = strstr(location,"SONGS");
if (s == 0)
return "";
else
return s+6;
}

To move files from the mp3 player to the computer, I use the script
player2comp:

where=`pwd`
name=`artist "$where"`
mkdir -p ~/SONGS/"$name"
for s in "$@"
do
cp "$s" ~/SONGS/"$name"/"$s"
done

As with comp2player, the directory hierarchy is preserved (and created,
if necessary).
Reply With Quote
  #2 (permalink)  
Old 2nd Feb 2007, 9:08 am
New Member
 
Join Date: Feb 2007
Posts: 7
Default

Sorry, my indentation was lost which makes the code a little hard to read. Computers are hard!
Reply With Quote
Reply

Sponsored Links



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux, ZSP, DSP, SDK, and all-all-all WIZARD General Discussion 0 21st Feb 2009 6:20 am
HOWTO: Make high-quality AMVs, without pre-processing santiagokq Video related 3 18th Feb 2008 5:35 pm
Howto: The perfect AMV Th3_uN1Qu3 Video related 8 25th Nov 2007 5:39 am
Howto: Properly recharging your MPx player Th3_uN1Qu3 Support and How To 2 24th Jul 2007 3:30 am
Howto keep player from dying overnight, even tho its off? Rocker81 Support and How To 1 24th Jul 2006 10:22 am


All times are GMT -7. The time now is 10:03 am.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0 RC 2
Back to Top

Designed by indiqo.media