withExtension

emlib.filetools.withExtension(filename, extension)[source]

Return a new filename where the original extension has been replaced with extension

Parameters:
  • filename (str) – the filename to modify

  • extension (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