Skip to main content
February 17, 2009
Question

How to find path?

  • February 17, 2009
  • 9 replies
  • 975 views
From this path...
srv01/iplant/home/apps/dir.txt


<cfset path = 'srv01/iplant/home/apps/dir.txt'

i want to find filename and path....

<cfset filename = listlast(path,'/')>
filename : <cfoutput>#filename#</cfoutput><br />



How will i find filepath?
filepath = srv01/iplant/home/apps/

    This topic has been closed for replies.

    9 replies

    Inspiring
    February 18, 2009
    <cfset fullpath = "srv01/iplant/home/apps/dir.txt">
    <cfoutput>
    file: #getfilefrompath(fullpath)#<br />
    dir: #getdirectoryfrompath(fullpath)#
    </cfoutput>


    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    February 17, 2009
    Amm85 wrote:
    > I getting this path from a text file...
    > then parsing this path to find
    > filename and filepath.
    >
    > so i can't use getDirectoryFromPath

    Why not? Is it not a path? If it is a path, I would expect
    getDirectoryFromPath() to remove the file from the end and return the
    rest of the list. Probably using the above mentioned listRest()
    function internally.

    Inspiring
    February 17, 2009
    Amm85 wrote:
    > Thanks Ian,
    >
    > i want last element removed...
    > ListRest
    >
    > Description
    >
    > Gets a list, without its first element.
    >

    Not uncommon and fairly easy to flip an list.
    February 17, 2009
    I getting this path from a text file...
    then parsing this path to find
    filename and filepath.

    so i can't use getDirectoryFromPath
    February 17, 2009
    Thanks Ian,

    i want last element removed...
    ListRest

    Description

    Gets a list, without its first element.
    Inspiring
    February 17, 2009
    Amm85 wrote:
    > we got a list function to remove an element in list?

    Yes, check out listrest().

    But in reality, I would use the ever so handy getDirectoryFromPath()
    function.

    I.E.
    <cfoutput>#getDirectoryFromPath(getCurrentTemplatePath())#</cfoutput> is
    a pretty useful construct.
    February 17, 2009
    Path always changes...

    so i want to remove filename in path...

    how can i do?

    filepath = path - filename
    February 17, 2009
    we got a list function to remove an element in list?
    davidsimms
    Inspiring
    February 17, 2009
    1. Treat srv01/iplant/home/apps/dir.txt as slash-delimited list.
    2. Remove the last element in that list.