[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Mutagen File Problem

aiwarrior

3/12/2008 2:00:00 PM

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'
1 Answer

Max Erickson

3/12/2008 4:13:00 PM

0

aiwarrior <zubeido@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