'extract.constant' takes a vector input and returns the single non-missing
value of the vector if there is one.  If the input has multiple non-missing
value, then an error is generated.

'extract.extension' takes a vector of file names and returns the extensions
of every file.  
Note that file names can be preceded by paths but the
paths must use '/' or '\\' and not '\' to indicate subdirectories.
By default ('lower' == TRUE), the extensions are all transformed to
lower case; to transform all extensions to upper case, set 'lower' to FALSE.
To leave all extension in the case in which they were input, set 'lower'
to NA.

extract.filename extracts the file name from a string that indicates its path + file name.  It can take a vector as input; in this case, it returns the vector of file names without the paths.  By default, all filenames are returned in the same case as the input.  If the input is a path that does not end in a filename, then extract.filename returns NA.  

ARGUMENTS:

Set lower = TRUE to convert all outputted characters to lower case.

Set No.Names = FALSE to return a vector of outputs that is named by the inputted path + file name vector. 

Set extension = FALSE to return the filename without an extension.

POSSIBLE REVISION:
Consider using the basename function as part of this function.  The basename function is not quite the equivalent of the extract.filename function.  

The following produce identical outputs:
    basename( "e:/r/fns/ls.jm.docm" )
[1] "ls.jm.docm"
    extract.filename( "e:/r/fns/ls.jm.docm" )
[1] "ls.jm.docm"

The following do not produce identical outputs:
    basename( "e:/r/fns" )
[1] "fns"
    extract.filename( "e:/r/fns" )
[1] NA

Also,
    basename( "e:/r/fns/" )
[1] "fns"
    extract.filename( "e:/r/fns/" )
[1] NA

Also, note that extract.filename uses a heuristic to decide whether a path that ends in a string that contains a period "." denotes a folder or a file name.  For example, 
extract.filename( "e:/cb/cs.str" )
[1] NA
This call to extract.filename returns NA because the directory (folder) "e:/cb/cs.str" exists on my computer.  
extract.filename( "e:/cb/cs.xyz" )
[1] "cs.xyz"
This call to extract.filename returns "cs.xyz" because the directory "e:/cb/cs.xyz" does not exist on my computer.