Here is the code I am working on:
from qgis.core import*
import glob, os, shutil, time, qgis
path = r"C:\Temp\testinput"
dest = r"C:\Temp\testoutput"
fname = []
for root,d_names,f_names in os.walk(path):
for f in f_names:
if f.endswith('.kml'):
src = os.path.join(root,f)
print(time.strftime('%m/%d/%Y', time.gmtime(os.path.getmtime(src))))
print(os.path.realpath(src))
shutil.copy2(src, dest)
this code transverses through the directory and copies the files but does overwrites files with the same name. How do I prevent the overwriting part? I would like to have the same type of filed renamed to "filename-copy" if it catches a file with the same name in the new folder.