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_pathis a file anddst_pathis an existing folderOSError – if
src_pathis a folder anddst_pathis an existing file (not raised under Windows)OSError – if
dst_pathis a non-empty folder, different fromsrc_path, andsrc_pathis also a folderOSError – if
dst_pathis an empty folder, different fromsrc_pathandsrc_pathis also a folder (raised only under Windows)
Examples
>>> path = audeer.mkdir("folder") >>> src_path = audeer.touch(path, "file1") >>> dst_path = os.path.join(path, "file2") >>> audeer.move(src_path, dst_path) >>> audeer.list_file_names(path, basenames=True) ['file2']