I can get the filename without extension using fileparts
>> f = '/foo/bar/file.gz'
>> [~,filename,~] = fileparts(f)
filename =
'file'
However if the file has multiple extensions, only the last one will be removed
>>f = '/foo/bar/file.gz.tar'
>>[~,filename,~] = fileparts(f)
filename =
'file.gz'
I know it's ambiguous what the file extension could be with multiple dots, but is there a way I can specify, for example, that both .gz and .gz.tar should be removed?