Copy link to clipboard
Copied
I have a file name as below :
2009 Master Calendar (4.2.09).xls
Now how to use list funtions ie.listfirst or listlast to display the file name alone without the file ext.
ie,.2009 Master Calendar (4.2.09)
Copy link to clipboard
Copied
Are the docs somehow unclear? You did read the docs, right?
http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7b62.html
What did you try, and in what way did it not work?
--
Adam
Copy link to clipboard
Copied
I used it as
<cfset filename=listfirst(#dirsOnly.Name#,'.')>
But i got the output as
2009 Master Calendar (4
Copy link to clipboard
Copied
But you can see why that's happening, right? That *is* the first element of a dot-separated list, innit? So what you probably need to do is to revise your thinking slightly, and approach it from "how do I get rid of the last element of a list" (the file extension is the last element of a dot-delimited list.
How do you delete stuff from a list?
--
Adam
Copy link to clipboard
Copied
<cfset a = "2009 Master Calendar (4.2.09).xls">
<cfset b = len(listlast(a,'.'))>
<cfset c = left(a,len(a) - b - 1)>
<cfoutput>#c#</cfoutput>
Copy link to clipboard
Copied
That's a lot more work that it needs to be. One can use listDeleteAt() to drop the last item from the list.
--
Adam