Get File Extension

Need help figuring out how to extract the file extension from a files filename.

I have a list of files attached to an item, but I would like a separate repeating group pulling in all the files but filtered to the files of type “jpg” or “png”, and have those images shown as thumbnails.

Thanks,
Chris

Just a thought:

You could create a small database table with all of the file types. Then filter files that contain a specific file type from your database.

There might be better ways to do this. Not sure, but this should work fine.

Hi im new hear so there maybe a much friendlier way to do this! However I just had a play with some regex to get the file extension. However after reading your question in more detail I dont think thats what you after ill have a little further play and see what I come up with.


1 Like

That’s great! I was playing with the regex extract but it was not working for me. Your suggestion worked perfectly.

I just applied that regex pattern to an advanced list filter and got the expected results first try.



Thanks again!
Chris

2 Likes

So an update to this just been playing around, it doesn’t look as though you can add a regex pattern into a constraint. So the only way you can do this is to save the file ending into the database long with the file. So that you can then add a constraint to say that the filetype must equal .png or whatever.

Unfortnatley I don’t think the contains argument will work as it would need to be a full word so you couldn’t use that on the file type thats saved by default in the database (as far as I can see) as it will be a string like s3://something/or/other/myfilename.png so the contains argument wont work on that as the whole word is “s3://something/or/other/myfilename.png” I believe this is due to scalability issues doing part word searches. However as you are uploading files if you can grab the type using regex and then save it in th DB then do a contains on the file ending.

Hope that makes sense and if I am wrong about any of this I apologise only been here a week! So please let me know :smiley:

Ah perfect glad it worked! I’ve not worked with lists yet so didnt think that would of been possible! I was trying to do it at the data source part when I was messing with things. But I assume the only potential issue is that all files will be loaded as part of that and not just the parts you need (which would help with the constraints).

This topic was automatically closed after 70 days. New replies are no longer allowed.