def move(src, dst):
"""
Recursively move a file or directory (src) to another location (dst).
If the destination is an existing directory, then src is moved inside that
directory. If the destination already exists but is not a directory, it may
be overwritten depending on os.rename() semantics.If the destination is on
the current filesystem, then os.rename() is used. Otherwise, src is copied
(using shutil.copy2()) to dst and then removed.
:Arguments:
src - source file to be moved
dst - target file/directory on which to be moved
:Return:
True/False - based on the success/failure of the operation
"""
status = False
try:
shutil.move(src, dst)
print_info("move of src {} to dst {} successful".format(src, dst))
status = True
except Exception as e:
print_error("moving file {} to file {} raised exception {}".
format(src, dst, str(e)))
return status
评论列表
文章目录