from genericpath import exists
import os
# Current working path
dir = os.getcwd()
# Change to specified path
dir = os.chdir(r'./fire')
path = '/data1/zcz/PythonRequest/fire'
file_list = os.listdir(path)
count = 1
if os.path.exists('../save_name.txt'):
with open('../save_name.txt', mode='r', encoding='utf-8') as file:
print(file.readlines())
f = open('../save_name.txt','a')
else:
with open("../save_name.txt", mode='w', encoding='utf-8') as file:
print(" File created successfully ")
f = open('../save_name.txt','a')
for file in file_list:
f.write(file + '\t\t')
olddir=os.path.join(path, file) # The original file path
filename=os.path.splitext(file)[0] # file name
filetype=os.path.splitext(file)[1] # File extension
str_name = "20220223_" + str(count) + filetype
newdir=os.path.join(path, str_name) # New file path
os.rename(olddir, newdir) # rename
count += 1
f.write(str_name + '\n')
We see the movie we wan
Hello everyone, I work in the