-3

What's the best way to copy and move files in python to a different directory, and overwrite those files in the destination if they already exist?

zeboidlund
  • 9,731
  • 31
  • 118
  • 180

2 Answers2

4

Take a look at shutil.copyfile

0
file1=open('insert directory here').readlines()
file2=open('insert directory here', 'w')
file2.write(file1)

If either of the directories have spaces in them do this:

directory='insert directory here'
directory=directory.rstrip()

Then use the variable directory as you would use the 'insert directory here'.

ThisIsAQuestion
  • 1,887
  • 14
  • 20