I need to move a lot of data to different locations on one drive, so cutting and pasting would be much faster. Currently, I'm just using shutil.copytree and shutil.rmtree, which works but it's slow.
Is there any way to cut/paste files instead of copy/delete?
The copy2() method in Python is used to copy the content of the source file to the destination file or directory. This method is identical to shutil. copy() method also preserving the file's metadata.
To copy files, you can use shutil. copy() . To find all JPEG files in the source directory, you can use glob. iglob() .
shutil.move()
>>> import shutil
>>> shutil.move(source, destination)
os.rename()
>>> import os
>>> os.rename(source, destination)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With