• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 128
  • Last Modified:

Using CFDIRECTORY - Need a variable to hold value of next level up the current path???

I have a variable that contains CurrentPath.  I want to be able to navigate to the upper level while using CFDIRECTORY.  Can someone help me determine how to find this value?  For example:

CurrentPath = C:\rootlevel\sub1\sub2\sub3
UpOneLevel = C:\rootlevel\sub1\sub2  (this is what I need)

Thanks in advance!
0
sulzener
Asked:
sulzener
  • 5
  • 3
  • 2
1 Solution
 
James RodgersWeb Applications DeveloperCommented:
take a look at getDirectoryFromPath

GetDirectoryFromPath(path)


give the directory from a fully specified path

Fully specified path (drive, directory, filename, and extension).

else you will need to use a regex
0
 
James RodgersWeb Applications DeveloperCommented:
you can also try

<cfdirectory action="list" directory="#expandPath('.')# &'/..'" name="fileList" sort="type,name">
0
 
sulzenerAuthor Commented:
Thanks Jester_48.  What I am really looking for is the basic logic to place the contents of CurrentPath into UpOneLevel minus the "\sub3".  Can you show me how to do that?
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
Renante EnteraCommented:
Hi sulzener!

Perhaps, this is what you are looking for :

<cfset CurrentPath = GetDirectoryFromPath(GetBaseTemplatePath())>

<cfdirectory action="list" directory="#CurrentPath#" name="fileList" sort="type,name" filter="*.*">

<cfloop query="fileList">
  <cffile action="copy" source="#CurrentPath#\#name#" destination="#CurrentPath#..">
</cfloop>

*Note : This is only applicable for copying all files from your current path to parent path.

Hope this helps you.  Just try it.


Goodluck!
eNTRANCE2002 :-)
0
 
sulzenerAuthor Commented:
All, sorry about this one.  I think I just didn't take the time to properly ask the question.   I can tell by the answers I didn't decribe what I am looking for very well.  Iwas just looking for a way to change a stringed value that happened to hold the current path.  I mentioned the CFDIRECTORY because that is what I am working with.  I really wasn't looking for CFDIRECTORY help.  My fault.  I kept looking on EE and was able to figure it out on my own.  I will award the points to you both:

<cfset MoveUpOneLevel = #GetDirectoryFromPath(currentpath)#>
<cfset Session.DocsCurPath = left('#MoveUp#',len('#MoveUp#')-1)>      
0
 
sulzenerAuthor Commented:
Wow, I'm so messed.  I see now that Jester_48 was the one who gave the right answer the first ime!  Thanks!
0
 
sulzenerAuthor Commented:
Also, the cfset of "MoveUpOneLevel" should be "MoveUp" in my example just posted!
0
 
James RodgersWeb Applications DeveloperCommented:
glad i could help

thanks for the points
0
 
sulzenerAuthor Commented:
Jester_48, I just posted another question.  You might be able to solve.  Q_21394090
0
 
Renante EnteraCommented:
Hi sulzener!

> What I am really looking for is the basic logic to place the contents of CurrentPath into UpOneLevel minus the "\sub3".
   I thought this is what you are looking for #-o  Haven't you tried my code ???  It seems that you are isolating it.  I just want to know your feedback regarding it.


Regards!
eNTRANCE2002 :-)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now