Mercurial > libervia-backend
comparison sat/tools/common/files_utils.py @ 3246:5ba0b1cdd45b
tools (common/files_utils): put extra suffix before file extension
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 01 Apr 2020 22:29:43 +0200 |
parents | 559a625a236b |
children | e86b71b1aa31 |
comparison
equal
deleted
inserted
replaced
3245:2a0a16b906ac | 3246:5ba0b1cdd45b |
---|---|
28 @return (Path): unique path (can be the same as path if there is no conflict) | 28 @return (Path): unique path (can be the same as path if there is no conflict) |
29 """ | 29 """ |
30 ori_path = path = Path(path) | 30 ori_path = path = Path(path) |
31 idx = 1 | 31 idx = 1 |
32 while path.exists(): | 32 while path.exists(): |
33 path = ori_path.with_name(ori_path.name + f"_{idx}") | 33 path = ori_path.with_name(f"{ori_path.stem}_{idx}{ori_path.suffix}") |
34 idx += 1 | 34 idx += 1 |
35 return path | 35 return path |