i have some pieces of mp3 that's recovered from my damaged hard disk. then i found some of the mp3s had been damaged, but some were ok. so, i'm using the following code to filter those damaged mp3s. `
import os
from pydub import AudioSegment
fname= 'C:\\Users\\Desktop\\1.mp3'
try:
sound1 = AudioSegment.from_file(fname)
except:
print(fname)
base, extension = os.path.splitext(fname)
p, name = os.path.split(base)
os.rename(fname, p + '\\' + name + '[damaged]' + extension)
`
but in the os.rename part, it prints error:PermissionError: [WinError 32]
it suggests that the file has been occupied by python programe.
how to solute the problem? thanks