Python copy not move

HI: I have a process where we email our invoices as pdf's to customers. I then extract the pdfs,  rename, and move to another directory using the python script below. The original files begin with the customer number; the renamed files begin with the date - so they can be sorted differently in explorer. However, the python script MOVES the file so I have been losing the originals and of course I sometimes need to sort invoices by customer (the first three characters of the original pdf). Does any python expert know how to change the script below from a MOVE process to a COPY?
Thanks!

target = ('C:\pythonrename\\files')
destination = ('C:\pythonrename\\invoices\\')
os.chdir(target)
allfiles = os.listdir(target)
for filename in allfiles:
    t = os.path.getmtime(filename)
    v = datetime.datetime.fromtimestamp(t)
    x = v.strftime('%Y%m%d')
    p = filename
    py = p[0:3]
    newstuff = (destination + x + "_" + py +".pdf")
    if not  os.path.isfile(newstuff):
                  os.rename(filename, newstuff)
Richard TeasdaleFinancial ControllerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
Try using copy from shutil.
shutil.copy(filename, newstuff)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard TeasdaleFinancial ControllerAuthor Commented:
Thanks, Norie. You are a star.
0
peprCommented:
Have a look also at shutil.copy2 that tries to preserve metadata (like last modification time -- if it matters).
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.