You can remove the extension from the file name using the string command:
echo (string split -r -m1 . $filename)[1]
This will split the filename into the filename right dot and print the first element of the resulting list. If there is no dot, this list will contain one element with filename .
If you also need to remove the leading directories, merge them with the base name:
echo (basename $filename | string split -r -m1 .)[1]
In this example, string reads input from standard input rather than passing the file name as an argument to the command line.
Claudio
source share