source_files = '/PATH/TO/DIR1/*'
destination_folder = '/PATH/TO/DIR2'
When the source and destination are decided like that, I want to move the file
I looked up the os module, but there is no copy function, so I ask you a question here.
mv (mv /PATH/TO/DIR1/* /PATH/TO/DIR2
) with Linux commands.
Which module has a function that does the same thing as ?
file python move
os.rename (src, dst, *, src_dir_fd=None, dst_dir_fd=None) rename the file/directory from src to dst.
shutil.move(src, dst, copy_function=copy2) recursively moves the file/directory (src) to another location (dst)
import os
os.rename("/PATH/TO/DIR1/*", "/PATH/TO/DIR2")
import shutil
shutil.move("/PATH/TO/DIR1/*", "/PATH/TO/DIR2")
© 2024 OneMinuteCode. All rights reserved.