Hello everyone,
Request you help with the following: I have updated the script which semi works.
import mutagen, xlrd, glob, re, openpyxl, os
# from mutagen.easyid3 import EasyID3
from os import walk
from pprint import pprint
from tinytag import TinyTag, TinyTagException
from openpyxl import Workbook
from openpyxl.utils import get_column_letter
from mp3_tagger import MP3File
from string import ascii_uppercase
filenames = os.listdir('E:\\All of D Drive\\Mixes\\') # directory path of files
number_files = len(filenames)
def ExtractMP3TagtoExcel():
print('Starting Program')
tracks = []
gettags = []
for root, dirs, files, in os.walk('E:\\All of D Drive\\Mixes\\'): #('C:\\Users\\mrdrj\\Desktop\\sdf\\'):
for name in files:
if name.endswith(('.mp3', '.m4a', '.flac', '.alac')):
tracks.append(name) # Add Media Files
try:
temp_track = TinyTag.get(root + '\\' + name)
mp3 = MP3File(root + '\\' + name)
# tags = mp3.get_tags()
print(root, '-', temp_track.artist, '-', temp_track.title)
gettags2 = [temp_track.album, temp_track.albumartist, temp_track.artist, temp_track.audio_offset,
temp_track.bitrate, temp_track.comment, temp_track.composer, temp_track.disc,
temp_track.disc_total, temp_track.duration, temp_track.filesize, temp_track.genre,
temp_track.samplerate, temp_track.title, temp_track.track, temp_track.track_total,
temp_track.year] # Add Tags to list
gettags.append(gettags2)
except TinyTagException:
print('Error')
wb = Workbook()
dest_filename = '-11empty_book11-.xlsx'
#newFile = dest_filename
#worksheet = wb.active
ws1 = wb.active
#ws = wb.active
ws1.title = "MP3 Tags" # Main Tab
#sheet = "MP3 Tags"
sheet = wb['MP3 Tags']
ws1['A1'] = 'Album'
ws1['B1'] = 'Contributing Artists'
ws1['C1'] = 'Title'
ws1['D1'] = 'Total Number of Disk'
ws1['E1'] = 'Genre'
ws1['F1'] = 'Disc Number'
ws1['G1'] = 'Track Duration'
for i in range(0,len(gettags)):
e=sheet.cell(row=2+i,column=1)
e.value = "{0}".format(gettags[i]) #gettags[i]
print(gettags[i])
wb.save(filename=dest_filename)
ExtractMP3TagtoExcel()
In that it put the data to the excel spreadsheet for example show below but it does not separate them by the commas into the spread sheet to the headers of Album, Artist, Title, etc. Why does it do it and how can I solve it? Thanks for your time.
[‘’, ’ A.R.P & U. T Dread’, ’ A.R.P & U. T Dread’, 484185, 320]
[None, None, None, 2136, 320]