I want to copy some files using python. Can someone tell me how to use the shutil.copy() command properly? thanks

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

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)
commented: love the paths! +18
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.