Skip to content

Filename extensions: .txt, .csv, .json ...

Dr. Nicola Mingotti edited this page Dec 11, 2021 · 1 revision

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' "
Clone this wiki locally