I have some code which adds the word \"_manual\" onto the end of a load of filenames.. I need to change the script so that it deletes the last two letters of the filename (ES)
you could do:
for filename in filenames: print(filename) #should display AC-5400ES.txt filename = filename.replace("ES.txt","ES_manual.txt") print(filename) #should display AC-5400ES_manual.txt fullpath = os.path.join(root, filename) os.rename(fullpath, filename)