fnExtension function

Change file name extension

Change file name extension

Very simple but often applicable function to retrieve or change the file name extension (from say file.lst to file.mod)

fnExtension(fn, ext)

Arguments

  • fn: file name. Often ending in an extension after a period but the extension is not needed.
  • ext: new file name extension. If omitted or NULL, the extension of fn is returned.

Returns

A text string

Examples

fnExtension("file.lst",".mod") fnExtension("file.lst","mod") fnExtension("file.lst","..mod") fnExtension("file.lst",cc(.mod,xml)) fnExtension(cc(file1.lst,file2.lst),cc(.xml)) fnExtension(cc(file1.lst,file2.lst),cc(.xml,.cov)) fnExtension("file.lst","") fnExtension("file.lst")
  • Maintainer: Philip Delff
  • License: MIT + file LICENSE
  • Last published: 2025-03-21