Info Zone

Hiking On The Web For Technology

script to convert mp3 files to ogg files

August 7th, 2006 by Henry Addo

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 )

Posted in |

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.