Hi,
I am trying to finish this function so that it cycles through all the songs in a folder and put the MP3 Tags into excel. How do I do the code below so it cycles through the MP3s Tags and add them into the excel document instead of hard coding them? Thanks
def ExtractMP3TagtoExcel():
print('Start')
tracks= []
gettags =[]
for root, dirs, files, in os.walk('C:\\Users\\mrdrj\\Desktop\\sdf\\'):
for name in files:
if name.endswith(('.mp3','.m4a','.flac','.alac')):
tracks.append(name)
try:
temp_track = TinyTag.get(root + '\\' + name)
gettags =[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]
print(root, '-',temp_track.artist, '-', temp_track.title)
except TinyTagException:
print('Error')
print(list)
print(gettags)
print('This is the name')
wb = Workbook()
os.chdir('C:\\Users\\mrdrj\\Desktop\\cqq\\Brimstone CD 3\\')
dest_filename = '11empty_book1.xlsx'
ws1 = wb.active
ws1.title = "MP3 Info" # Main Tab
for col in range(1, 2): # How many Tabs
#ws1.append(range(5)) #Row Add values
for row in range(2, number_files):
for col in range(1, 8): # Number of colums static
_ = ws1.cell(column=col, row=row, value ='Test') #value="{0}".format(get_column_letter(col)))
ws1['A1'] = 'Album'
ws1['A2'] = temp_track.album
ws1['B1'] = 'Contributing Artists'
ws1['B2'] = temp_track.artist
ws1['C1'] = 'Title'
ws1['C2'] = temp_track.title
ws1['D1'] = 'Total Number of Disk'
ws1['D2']= temp_track.disc_total
ws1['E1'] = 'Genre'
ws1['E2'] = temp_track.genre
ws1['F1'] = 'Disc Number'
ws1['F2'] = temp_track.disc
ws1['G1'] = 'Track Duration'
ws1['G2'] = temp_track.duration/60
ws1['I2'] = col
#print(temp_track)
#ws1['H1'] = 'Name'
#ws1['H2'] =
#print('This track is by %s.' % temp_track.artist)
#print('It is %f seconds long.' % temp_track.duration)
#ws1['D2'] = temp_track.name
#print(temp_track.track_total)
#ws2 = wb.create_sheet(title="P") #Second Tab
row = 2
col = 2
#ws2['F5'] = 3.14 # Add value to specific Tab
ExtractMP3TagtoExcel()