Filename extensions

From Cuis CookBook
Revision as of 20:35, 4 May 2025 by Nmingott (talk | contribs) (imported material)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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' "