I'm trying to rename a folder that has a set of files, I want to remove all the digits from the file names. But when I try to run the code the error message appears: "invalid syntax", pointing specifically to the os module. Can anyone tell me the reason for the error and how can I fix it? Here is the code:
import os
def rename_files():
#(1) pegue os nomes dos arquivos da pasta
file_list = os.listdir(r"C:\Projetos\arquivos")
#print(file_list)
saved_path = os.getcwd()
print("Curret Working Directory is "+saved_path)
os.chdir(r"C:\Projetos\arquivos")
#(2) para cada arquivo, renomeie o nome do arquivo
for file_name in file_list:
print("Old Name - "+file_name)
print("New Name - "+file_name.translate(None, "0123456789")
os.rename(file_name, file_name.traslate(None, "0123456789"))
os.chdir(saved_path)
rename_files()