Feb-16-2021, 08:48 PM
Try this and tell me if it prints out the files that you want to change and the names that you want to change them to.
import os path = r"/Users/princessnaana/Desktop/Python_Examples/Naana" directory_list = os.listdir(path) for f in directory_list: if '[' in f and ']' in f : dst = f[f.find('[') + 1:].replace(']','') print (f, dst)