3
Contributors
2
Replies
5
Views
8 Years
Discussion Span
Last Post by Ene Uran
0

I'm confused. Here's the help on shutil.copy:

>>> help(shutil.copy)
Help on function copy in module shutil:

copy(src, dst)
Copy data and mode bits ("cp src dst").

The destination may be a directory.

Can you be specific with your question?

Thanks,
Jeff

1

Expanding on jrcagle post:

import shutil

source_file = r"C:\Python25\Atest\Bull\shutil_test.txt"
destination = r"C:\Python25\Atest\Bull\Test"

# this copies the source file to the destination directory
# the destination directory has to exist
# if the filename already exists there, it will be overwritten
# access time and last modification time will be updated
# the same filename is used
shutil.copy(source_file, destination)

destination2 = r"C:\Python25\Atest\Bull\Test\shutil_test2.txt"
# similar to above,
# but the new specified filename is used
shutil.copy(source_file, destination2)

destination3 = r"C:\Python25\Atest\Bull\Test\shutil_test3.txt"
# similar to above,
# but the new specified filename retains the original file dates
shutil.copy2(source_file, destination3)
Votes + Comments
love the paths!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.