Arquivo de renomeação do Python
import os
os.rename('guru99.txt','career.guru99.txt')
Cirex
import os
os.rename('guru99.txt','career.guru99.txt')
import os
os.rename('old_name.txt','new_name.txt')
import os
for dirname in os.listdir("."):
if os.path.isdir(dirname):
for i, filename in enumerate(os.listdir(dirname)):
os.rename(dirname + "/" + filename, dirname + "/" + str(i) + ".bmp")
import os
old_file_name = "/home/career_karma/raw_data.csv"
new_file_name = "/home/career_karma/old_data.csv"
os.rename(old_file_name, new_file_name)
print("File renamed!")
import os
os.rename(r'C:\Users\Ron\Desktop\Test\Products.txt',r'C:\Users\Ron\Desktop\Test\Shipped Products.txt')
# for multiple files
import os
for dirname in os.listdir("."):
print((dirname[:-4]).zfill(6)+'.txt')
os.rename(dirname, (dirname[:-4]).zfill(6)+'.txt')