23

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?

Ryan
  • 251
  • 1
  • 2
  • 5

1 Answers1

64

shutil.move()

>>> import shutil
>>> shutil.move(source, destination)

os.rename()

>>> import os
>>> os.rename(source, destination)
Adem Öztaş
  • 20,457
  • 4
  • 34
  • 42
  • 2
    You may want to edit your answer for one correction: You have the `source` and `destination` swapped, so it should be `shutil.move(source, destination)`. –  Jun 24 '16 at 13:13