Mutagen File Problem

Max Erickson maxerickson at gmail.com
Wed Mar 12 12:12:48 EDT 2008


aiwarrior <zubeido at yahoo.com.br> wrote:

> Hi i'm having a IO error saying a file does not exist even though
> i perform a isFile() check. Can you help me out figuring what is
> wrong? 
> 
> Thanks in advance
> 
> from mutagen.easyid3 import EasyID3
> from mutagen.mp3 import MP3
> 
> for root, dirs, files in os.walk('''C:\\Documents and
> Settings\\pneves\ \Music\\''', topdown=False):
>         for name in files:
>             joined = os.path.join(root, name)
>             if (name[-3:] == 'mp3' ):
>                 audio = MP3(joined, ID3=EasyID3)
>                 if not audio.has_key('album') and
> os.path.isfile(joined):
>                        print os.path.join(root, name)
> 
> I get an error as following:
> 
> IOError: [Errno 2] No such file or directory: 'C:\\Documents and
> Settings\\pneves\\Music\\Naked Music - Miguel Migs - Colorful
> You\ \Miguel Migs - Colorful you - Full album\\Miguel Migs -
> Colorful you - Cd 2 -Mixed and mastered by J. Mark Andrus\\7 -
> Miguel Migs feat. Lisa Shaw - You Bring Me Up (Main Vocal
> Mix).mp3' 

It looks like the error is happending in MP3(join...), so the 
os.path.isfile check is never reached. If that is the case, 
something along the lines of:

try:
    audio=MP3(joined, ID3=EasyID3)
except: #catches any error in MP3...
    print joined

should suppress the error and print the filename that triggered it.


max




More information about the Python-list mailing list