MCPcopy Index your code
hub / github.com/geekcomputers/Python / unique_name

Function unique_name

photo_timestamp_renamer.py:92–104  ·  view source on GitHub ↗

If base.ext exists, append _01, _02, ...

(dest_dir: Path, base: str, ext: str)

Source from the content-addressed store, hash-verified

90
91
92def unique_name(dest_dir: Path, base: str, ext: str) -> Path:
93 """
94 If base.ext exists, append _01, _02, ...
95 """
96 cand = dest_dir / f"{base}{ext}"
97 if not cand.exists():
98 return cand
99 i = 1
100 while True:
101 cand = dest_dir / f"{base}_{i:02d}{ext}"
102 if not cand.exists():
103 return cand
104 i += 1
105
106
107@dataclass

Callers 1

rename_photosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected