Mp3 batch modify the name by python

Software download songs: Music mad

Download format: [xxxx] xxxx.mp3

import os
import re

path = 'c:\\test'

old_dir = os.listdir(path)
print ( 'original file name S%'% old_dir) 
for I in old_dir:
SPLi = i.split ( ']')
Print (SPLi)

the os.chdir (path)
NEW_NAME = SPLi [. 1] # STEP. 1
Print (NEW_NAME )
#
os.rename (i, new_name)

but in execution time to step 1 will prompt the following error:
  

new_name = spli[1]
IndexError: list index out of range  

Song names are in this format, may really be the reason Chinese characters of the name are, because print (spli [0]) when they are not being given.

 

 

This copy a small part of the song and then perform the ok song files in the original 550 in the verification process after in the

 

Will someone tell me why it would exceed the range

 

 

Guess you like

Origin www.cnblogs.com/jarrel/p/listi_outofrange.html