Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to find path?

Guest
Feb 17, 2009 Feb 17, 2009
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/

914
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 17, 2009 Feb 17, 2009
1. Treat srv01/iplant/home/apps/dir.txt as slash-delimited list.
2. Remove the last element in that list.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 17, 2009 Feb 17, 2009
we got a list function to remove an element in list?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 17, 2009 Feb 17, 2009
Path always changes...

so i want to remove filename in path...

how can i do?

filepath = path - filename
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2009 Feb 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 17, 2009 Feb 17, 2009
Thanks Ian,

i want last element removed...
ListRest

Description

Gets a list, without its first element.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 17, 2009 Feb 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2009 Feb 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2009 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2009 Feb 17, 2009
LATEST
<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/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources