为mp3曲目编号时,仅在某些文件上出现此python脚本错误

为mp3曲目编号时,仅在某些文件上出现此python脚本错误,python,mutagen,windowserror,Python,Mutagen,Windowserror,这是我做的一个脚本,将曲目编号放在MP3名称之前,以保持曲目的正确顺序,而不是按字母顺序排列 除了三个文件夹外,它在所有文件夹(100多个文件夹/1300多首歌曲)上都运行良好 我不知道世跆拳道在这里发生了什么 有人有什么想法吗 output => 输入音乐文件的路径:/n>c:\test path_name=c:\test\2-Live Albums\1995-MTV未插拔\Shooting Star.mp3 02-Shooting Star.mp3 path_name=c:\tes

这是我做的一个脚本,将曲目编号放在MP3名称之前,以保持曲目的正确顺序,而不是按字母顺序排列

除了三个文件夹外,它在所有文件夹(100多个文件夹/1300多首歌曲)上都运行良好

我不知道世跆拳道在这里发生了什么

有人有什么想法吗

output => 
输入音乐文件的路径:/n>c:\test

path_name=c:\test\2-Live Albums\1995-MTV未插拔\Shooting Star.mp3

02-Shooting Star.mp3

path_name=c:\test\2-Live Albums\1995-MTV拔下插头\TheTimes A-Changin'.mp3

04年的今天,《纽约时报》报道了他们的变化 3. path_name=c:\test\2-Live Albums\1995-MTV未插拔\Tombstone Blues.mp3 01-墓碑蓝调.mp3

path_name=c:\test\2-Live Albums\1995-MTV-plugged\With God On Our Side.mp3

12-上帝站在我们这边

path_name=c:\test\1-Studio Albums\1964-TheTimes That A-Changin\Hollis Brown.mp3民谣

回溯(最近一次呼叫最后一次):

文件“C:/Users/Brian/Python Files/track_numbering_mp3.py”,第45行,在

音乐\曲目\编号(路径)

文件“C:/Users/Brian/Python Files/track\u numbering\u mp3.py”,第39行,音乐曲目编号

重命名(join(root,name),join(root,track_number))35;重命名文件

WindowsError:[错误3]系统找不到指定的路径

进程已完成,退出代码为1

#!usr/bin/env python
__author__ = 'Brian Kane'

"""This scripts takes a path argument to the root directory of the music files (mp3 here) and
   adds a padded number corresponding to the track number.  It will do this to all of the tracks in the folders
   and subfolders.  This allows for burning in the track order and not alphabetized.  In theory I suppose you could
   start at C:'\'"""

import os
from os.path import *
import string
from mutagen.mp3 import MP3
from mutagen.easyid3 import EasyID3


def music_track_numbering(path):
    nums = []

    for i in range(10):                                                     # just fills in nums to compare to track name
                                                                            # to not double number
        nums.append(str(i))

        for root, dirs, files in os.walk(path):                             # walks through the data tree to get files
            # print 'root = ', root
            # print 'dirs = ', dirs
            # print 'files = ',files
            for name in files:
                extension = os.path.splitext(name)[1][1:].strip().lower()  # gets the file extension

                if name[0] in nums:                                         # don't double number
                    break

                if extension == 'mp3':
                    # print 'name = ', name                                 # test purposes
                    path_name = root +'\\' + name                           # path_name is complete path
                    print 'path_name = ', path_name                         # test purposes
                    track = EasyID3(path_name)['tracknumber'][0]            # gets the track number from metadata
                    track_number = str(track).zfill(2) + ' - ' + name       # pads leading zero and adds dash to name
                    os.rename(join(root,name),join(root,track_number))      # renames the file
                    print track_number                                      # test purposes

# path = 'C:\\test'                                                         # this is a test path
path = raw_input('Enter the path to the music file:/n>')

music_track_numbering(path)

没有什么明显的东西向我扑来。在
os.rename()
之前添加一条print语句,以显示传递给该函数的参数。可能是权限问题,例如,无法写入目录?可能希望了解if print语句是否无效。尝试重命名文件夹,但某处正忙。是时候重新启动了。