Skip to main content

Hi there,



I have a conundrum that I hope someone can please help me with! It’s all about the final “/”



Basically I want to extract the last part of a file path + filename string, to leave only the filename. The path and name can all be different lengths, and have different folder depths. The key is to take everything AFTER the final “/” Examples below…



/Volumes/my_drive/documents/pictures/A001.jpeg


/mnt/usb/pictures/123456.tiff


/Server/over_there/no_really/this_one/what a long path/Big File.mov



would parse…



A001.jpeg


123456.tiff


Big File.mov



Any ideas please, fantastic Airtable community?



Thanks!

You could do it with REGEX_REPLACE()



REGEX_REPLACE(

{Field Name},

"^(.+)\\/([^\\/]+)$",

"$2"

)


You could do it with REGEX_REPLACE()



REGEX_REPLACE(

{Field Name},

"^(.+)\\/([^\\/]+)$",

"$2"

)


That’s amazing Kamille, thanks so much! Worked a charm, you got the skills! Appreciate it.


Cheers.


This is really a helpful solution!

I'm still stuck with another related issue. I need to extract the string from the second-to-last section of a file path, essentially to isolate the parent folder of a file or folder. I've looked into regular expressions and have found them to be a bit daunting, so I can't build upon this solution here. 

Using EastEndTom's sample, I need to extract "pictures"  from /Volumes/my_drive/documents/pictures/A001.jpeg.

Does anyone have any suggestions for me?

Thanks!


Reply