libb.safe_move

safe_move(source, target, hard_remove=False)[source]

Move a file to a new location, optionally deleting anything in the way.

Parameters:
  • source (str) – Source file path.

  • target (str) – Target file path.

  • hard_remove (bool) – If True, delete existing file at target first.

Returns:

Final target path (may differ if conflict occurred).

Return type:

Path

See also

See tests/test_dir.py for usage examples.