move()¶
- audeer.move(src_path, dst_path)[source]¶
Move a file or folder independent of operating system.
As
os.rename()
works differently under Unix and Windows andshutil.move()
can be slow, we useos.replace()
to move the file/folder.- Parameters
src_path – source file/folder path
dst_path – destination file/folder path
- Raises
OSError – if
src_path
is a file anddst_path
is an existing folderOSError – if
src_path
is a folder anddst_path
is an existing file (not raised under Windows)OSError – if
dst_path
is a non-empty folder, different fromsrc_path
, andsrc_path
is also a folderOSError – if
dst_path
is an empty folder, different fromsrc_path
andsrc_path
is also a folder (raised only under Windows)
Examples
>>> path = mkdir("folder") >>> src_path = touch(path, "file1") >>> dst_path = os.path.join(path, "file2") >>> move(src_path, dst_path) >>> list_file_names(path, basenames=True) ['file2']