Это может вам помочь.
import os
import datetime
import shutil
now = datetime.datetime.now()
path ='f:\\python\\testdir\\'
dest_folder='f:/python/testdir/copyfolder/'
files=[]
#check if destination folder exists if not create one
if os.path.exists(dest_folder):
#ignore nothing to do
pass
else:
print("not exits")
os.mkdir(dest_folder)
for r, d, f in os.walk(path):
for file in f:
# if '.txt' in file:
#print(os.path.join(r, file))
files.append(os.path.join(r, file))
for f in files:
print(f)
#extract the file name from the path
base_name=os.path.basename(f)
#extracting the file name and it's extension
file_name,ext=os.path.splitext(base_name)
#print(ext)
#file_name+='_'+now.strftime("%Y-%m-%d %H:%M")
#append the current time stamp and it's extension and move the file to new destination
shutil.copy2(f,'f:/python/testdir/copyfolder/'+file_name+'-'+now.strftime("%Y-%m-%d")+ext)
#print(file_name)