Filename extensions: Difference between revisions

From Cuis CookBook
Jump to navigation Jump to search
(imported material)
 
(No difference)

Latest revision as of 20:35, 4 May 2025

Problem. It is often necessary to decide what to do with a file looking at the last part of its name: the extension. In some system extensions are fundamental (Windows), in some other just decoration you could also omit (Linux/Unix). How do I extract the extension from a filename?

Solution. by example

'/home/p/foo.bar' asFileEntry nameWithoutExtension .    " =>  'foo' "
'/home/p/foo.bar' asFileEntry extension.                 "=>  'bar' "
'/home/p/foo.bar.bazar' asFileEntry extension.           "=> 'bazar' "