Mr. Test
Mr. Test

Reputation: 11

How to Open & Modify an Attribute of a Files' Properties using Python?

I've been having some troubles trying to determine a method in which I can open a files' property window, go to the Details tab and then edit one of the values of a specific value. In more detail, I have over 200 Mp3 files in a folder which I'd like to edit the Number Property Value to an increasing variable. Basically this is my prediction of what it will look like:

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

Anyways, all the help I can get it mighty appreciated. I look forward to your responses. NOTE I'm running on Windows 7.

Upvotes: 1

Views: 7125

Answers (1)

odie5533
odie5533

Reputation: 562

You might want to try eyeD3 which allows you to modify mp3 ID3 attributes:

 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()

Or you could use mutagen:

from mutagen.easyid3 import EasyID3
audio = EasyID3("example.mp3")
audio["title"] = u"An example"
audio.save()

Another option would be to use songdetails (check it out on Github. I can only post 2 hyperlinks):

import songdetails
song = songdetails.scan("data/commit.mp3")
if song is not None:
    song.artist = "Great artist"
    song.save()

I hope this helped. Cheers!

Upvotes: 3

Related Questions