How to extract filename in path in cell excel (formul)?

I have paths in Excel column and I want extract filename in other cell without VBA.

/where/is/my/path/filename.txt

I would like extract "filename.txt"

2 Answers

I share with you my finds.

I find this site :

=MID(A1,FIND("*",SUBSTITUTE(A1,"\","*",LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))))+1,LEN(A1))

But doesn't work on french Excel that's why I translate for French users :

=STXT(A1;CHERCHE("$";SUBSTITUE(A1;"/";"$";NBCAR(A1)-NBCAR(SUBSTITUE(A1;"/";""))))+1;NBCAR(A1))

I change "\" to "/" because I have unix path.

This will help:

var url = "/where/is/my/path/filename.txt";
var filename = url.substring(url.lastIndexOf('/')+1);
alert(filename);

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like