844
Views
7
Comments
Solved
String Split with file extension
Question

SyntaxEditor Code Snippet


i am storing file name in the table. need to retrieve the filename extension on the table record to display the extension alone in one of the table Column. how do i do it.

String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".")
2020-09-01 10-42-42
Stefano Valente
Solution

IF( String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".").length>1,

String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".")[1].Text.Value,"")


UserImage.jpg
Ellakkiya

RMS wrote:

SyntaxEditor Code Snippet


i am storing file name in the table. need to retrieve the filename extension on the table record to display the extension alone in one of the table Column. how do i do it.

String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".")

Hi RMS,

you can get the extension of the image from the output of the string split by using the below code

SyntaxEditor Code Snippet

String_Split.List[1].Text.Value




2025-01-09 14-56-57
IQ78

use this:

just drag and put yours accordingly:

2020-09-01 10-42-42
Stefano Valente
Solution

IF( String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".").length>1,

String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".")[1].Text.Value,"")


UserImage.jpg
Meenakshi Sundaram

Thanks for the prompt response, Worked Well.

2023-05-18 05-39-48
Kiruthika Balasubramanian

Hi

Here I have attached a file which contains a javascript on uploadonchange action that filters the extension of the file.

Hope this will helps.

Thanks

MultipleUpload.oml
2023-03-02 12-04-41
Márcio Lima

To those who might see the selected answer, it doesn't work for filenames with multiple dots. Example: filenames.can.have.dots.xlsx

A better solution is the following:

If( String_Split(Filename,".").Length>1,String_Split(Filename,".")[String_Split(Filename,".").Length -1].Text.Value,"")


I suggest you run the String_Split in its node to avoid running it 3 times.

2022-07-04 11-30-56
Manuel Glade

Another approach is to use the substr() method. Multiple dots within the filename do not matter, because the FileExtension is searched from behind. 


FileExtension = Substr(Filename,Length(Filename) - (Length(Filename) - Index(Filename,".",searchFromEnd:True) - 1),Length(Filename))


Filename = Substr(Filename,0,Index(Filename,".",searchFromEnd:True))


The file extension is searched by taking the filename and searching the index of the first point in the filename from behind. Start of the substring is the total length of the filename - the index of the first point from the end (in addition -1 is used to not include the dot in the extension).


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.