如何打开&;修改文件的属性';使用Python的属性?

如何打开&;修改文件的属性';使用Python的属性?,python,properties,Python,Properties,我在尝试确定一种方法时遇到了一些问题,在这种方法中,我可以打开文件的属性窗口,转到“详细信息”选项卡,然后编辑特定值的一个值。更详细地说,我在一个文件夹中有200多个Mp3文件,我想将Number属性值编辑为递增变量。基本上,这是我对它的预测: import os count = 0 directory = #directory of folder containing x amount of files files = os.listdir(directory) for i in files

我在尝试确定一种方法时遇到了一些问题,在这种方法中,我可以打开文件的属性窗口,转到“详细信息”选项卡,然后编辑特定值的一个值。更详细地说,我在一个文件夹中有200多个Mp3文件,我想将Number属性值编辑为递增变量。基本上,这是我对它的预测:

import os

count = 0
directory = #directory of folder containing x amount of files
files = os.listdir(directory)
for i in files:
    count += 1
    #some code to open up i's property window
    #some code to go to the details tab
    numberProperty = #some code to get the info of the Property's Value
    numberProperty = count
无论如何,我能得到的所有帮助都非常感激。我期待你的答复。 注意:我正在Windows 7上运行。

您可能希望尝试使用允许您修改mp3 ID3属性的功能:

 import eyeD3
 tag = eyeD3.Tag()
 tag.link("/some/file.mp3")
 print tag.getArtist()
 print tag.getAlbum()
 print tag.getTitle()
 tag.setArtist(u"Cro-Mags")
 tag.setAlbum(u"Age of Quarrel")
 tag.update()
或者您可以使用:

另一个选择是使用songdetails(在Github上查看,我只能发布2个超链接):


我希望这有帮助。干杯

测试时,请确保将代码缩进四个空格以获得正确的格式。感谢您快速而全面的回复。我相信这正是我想要的(由于时间限制,还没有机会使用它,但它似乎描述了我的要求)。顺便说一句,我知道这听起来很“初学者”,但如何安装这些文件呢?我习惯于将一个.exe文件解压到我的Python26源文件夹中,使用这些模块,我不想覆盖任何内容。我们也非常感谢您的帮助。诱变剂包含在页面上提供的二进制软件包中。这是一个普通的Windows安装程序。有关详细信息,您可以下载它,将其解压缩到某个位置,然后在该目录中运行
python setup.py install
from mutagen.easyid3 import EasyID3
audio = EasyID3("example.mp3")
audio["title"] = u"An example"
audio.save()
import songdetails
song = songdetails.scan("data/commit.mp3")
if song is not None:
    song.artist = "Great artist"
    song.save()