Python 3.5.1: Change File Name
import os import re def rename_files(): #get file names from a folder file_list = os.listdir('/Users/myname/Desktop/Python') #print (file_list) saved_path = os.getcwd() print(sav
removing all NUMBERS from the file names
If you're removing all numbers then why do you need an assertion: (?!\d*$)
When you can simply do:
os.rename(file_name, re.sub("[0-9]", "", file_name))
And you're doing it wrong:
os.rename(file-name, re.sub("[0-9](?!\d*$)", "", file_name))
# ^
Post a Comment for "Python 3.5.1: Change File Name"