I have a script that copy folder and files from their source to a new destination, the script works as it should using shutil
module. But I am hard coding the source for folders.
What I need is to make the script select the desired folder where it has a specific name. as
pdf 11-12-02-2020 so it pdf + date yesterday - current date - current month - current year.
how can I do this ?
code:
import os
import shutil
from os import path
import datetime
src = "I:\\"
src2 = "I:/pdf 11-12-02-2020"
dst = "C:/Users/LT GM/Desktop/pdf 11-12-02-2020/"
def main():
copy()
def copy():
if os.path.exists(dst):
shutil.rmtree(dst)
print("the deleted folder is :{0}".format(dst))
#copy the folder as it is (folder with the files)
copieddst = shutil.copytree(src2,dst)
print("copy of the folder is done :{0}".format(copieddst))
else:
#copy the folder as it is (folder with the files)
copieddst = shutil.copytree(src2,dst)
print("copy of the folder is done :{0}".format(copieddst))
if __name__=="__main__":
main()