Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find last occurrence of `/` in file path in coldfusion

In Coldfusion, I tried to find the function to find the index value of last occurrence of / in file path so that file name after / is picked up. can any body suggest me the solution. I want to retrieve file name from a file path.

like image 546
rique Avatar asked Nov 28 '22 08:11

rique


2 Answers

Use GetFileFromPath(filepath). It returns the file name from a given path.

<cfset fileName = GetFileFromPath(filepath)>
like image 90
coldfusiondevshop Avatar answered Dec 10 '22 03:12

coldfusiondevshop


You could either use listLast() to get the fragment of the string you want directly:

filePart = listLast(fullPath, "/\");

Or you could simply use java.lang.String's lastIndexOf() method to approach it exactly the way you describe.

However I'd just use listLast().

like image 25
Adam Cameron Avatar answered Dec 10 '22 05:12

Adam Cameron