openSUSE Forums > Archives > SF Archives > ARCHIVES - Tips, Tricks & Tweaks » A Couple Of Scripts For Fast N Easy Music Files Conversion

Go Back   openSUSE Forums > Archives > SF Archives > ARCHIVES - Tips, Tricks & Tweaks
Forums FAQ Members List Search Today's Posts Mark Forums Read


ARCHIVES - Tips, Tricks & Tweaks Tips and Solutions for SUSE Linux
(Please do not post questions here)

 
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 26-Mar-2007, 10:07
Paris _ Vanity Case.
Guest
 
Posts: n/a
Default

A friend of mine wrote a couple of simple and fast scripts for conversion of m4a and ogg music files to mp3. Here is how you can use them.

1. we need a folder where we keep scripts and this folder should be set as a path in .bashrc .
For example the folder /home/username/bin and the appropriate line in .bashrc:
Code:
#Paths
PATH="/home/username/bin:${PATH}"
2. in that folder create two new files m4a2mp3.sh and ogg2mp3.sh

3. make the files executables, in terminal:
Code:
chmod +x /home/username/bin/*
4. edit the files with your favorite editor and add these lines:
Code:
#!/bin/sh
IFS="
"
while [ "$#" -gt "0" ]
do
****echo converting $1
****if file $1 | grep "MPEG v4" >/dev/null
****then 
********x=`echo $1 | sed 's/\(.*\.\)m4a/\1wav/'`
********y=`echo $1 | sed 's/\(.*\.\)m4a/\1mp3/'`
********if faad -o $x $1 >/dev/null 2>&1 && lame -h $x $y >/dev/null 2>&1
********then echo OK!
************rm $1
************rm $x
********else echo FAILED
********fi
****else echo 'NOT an MPEG v4 file'
****fi
****echo ''
****shift
done
for the m4a2mp3.sh file and

Code:
#!/bin/sh
IFS="
"
while [ "$#" -gt "0" ]
do
****echo converting $1
****if file $1 | grep "Ogg data" >/dev/null
****then 
********x=`echo $1 | sed 's/\(.*\.\)ogg/\1wav/'`
********y=`echo $1 | sed 's/\(.*\.\)ogg/\1mp3/'`
********if oggdec -o $x $1 >/dev/null 2>&1 && lame -h $x $y >/dev/null 2>&1
********then echo OK!
************rm $1
************rm $x
********else echo FAILED
********fi
****else echo 'NOT an OGG file'
****fi
****echo ''
****shift
done
for the ogg2mp3.sh file.

5. now you can use the scripts to convert your files.
for example if you have some ogg files in /home/username/music/ you can type:
Code:
ogg2mp3.sh /home/username/music/*
to convert all of them. if there are any non-ogg files you will be notified and if you want to change specific files only you must type the exact path or cleverly use wildcards.

Please let me know if there are any typos or mistakes and let me thank Herc who wrote the scripts. Nice job Hercules!

PS: the scripts are licensed under GPL
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2