Renaming the file seems to be more frequent than expected in business, so I will write it as a memorandum.
import os
import glob
N = 8 #Delete 8 characters to delete YYYYMMDD from the file name
EXT = "*.txt"
DIR = r"C:\Users\dirname" #The file path prefix "r" may not be needed.
os.chdir(DIR)
for file in glob.glob(EXT):
os.rename(file,file[N:])
Recommended Posts