Google Ad

Tuesday, August 08, 2006

script to convert mp3 files to ogg files

I was a bit bored and not in the mood to do some real work and to refresh my python skills i came up with this small script that converts mp3 files to ogg files using the mp32ogg tool. The script depends on that tool.So it should be installed first before trying to run the script.
This script is really not fancy enough. Modification and additions are most welcome.

#! /usr/bin/python2.4

# script to convert mp3 files to ogg files this
# script depends on the mp32ogg tool for the conversion
# is just a script that accept path to mp3 files then
# calls the mp32ogg tool to converts

import os

# to collect vaules

def mp3Convertor( directory_path ):
#path to directory containing the mp3 files
source_directory = directory_path+'/*.mp3'

#directory to contain the ogg files
#the same as the source directory

#using the mp32ogg tool to convert the mp3 files
# ogg files
oggtool = "mp32ogg %s" % ( source_directory )

if os.system( oggtool ) == 0:
print 'The mp3 files has successfully been converted'

else:
print oggtool

#get path to the mp3 files from the user
source_path = raw_input('Enter path to mp3 files')

if len( source_path ) == 0:
print 'Please enter path to mp3 files'
else:
mp3Convertor( source_path )

1 comment:

Author said...

Thanks for the post..
Here is online free mp3 to ogg converter
convert mp3 to ogg