withExtension¶
- emlib.filetools.withExtension(filename, extension)[source]¶
Return a filename with its extension replaced
- Parameters:
filename (
str) – the filename to modifyextension (
str) – the new extension
- Return type:
str- Returns:
a filename with the given extension in place of the old extension
filename
extension
output
foo.txt
.md
foo.md
foo.txt
md
foo.md
foo.bar.baz
zip
foo.bar.zip