[Tutor] os.path.walk
Gus Tabares
gus.tabares@verizon.net
Fri Feb 21 20:29:02 2003
Hey all,
I'm trying to run this simple script and I'm not sure what the problem is.
Any help would be appreciated.
import os
def visit(arg, dirname, names):
for names in dirname:
if (names[-4:] != '.mp3'):
os.rename(names, (names[:-4] + '.mp3'))
else:
pass
dummy = []
os.path.walk("G:\\Mp3s", visit, dummy)
Here is the traceback:
Traceback (most recent call last):
File "mp3.py", line 19, in ?
os.path.walk("G:\\Mp3s", visit, dummy)
File "C:\Python22\lib\ntpath.py", line 318, in walk
func(arg, top, names)
File "mp3.py", line 12, in visit
os.rename(names, (names[:-4] + '.mp3'))
OSError: [Errno 2] No such file or directory
I am 100% positive my G:\Mp3s dir does exist:)