• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 130
  • 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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Renante EnteraSenior PHP DeveloperCommented:
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 EnteraSenior PHP DeveloperCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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