|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Array a directory name
Author: Keith McGee
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350850
How do you split a directory name into an array or remove a section from the
name?
Example
dir = Internet/Manuals/tests/doc.html
into
newdir = tests/doc.html
Thank you
Keith
Author: Raymond Camden
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350851
Did you try the listToArray function?
----- Excess quoted text cut - see Original Post for more -----
Author: Keith McGee
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350852
I tried this
<cfset arr = listToArray (filename, "/",false,true)>
received this error
Parameter validation error for the LISTTOARRAY function.
The function accepts 1 to 3 parameters.
The error occurred in repositoryView.cfm: line 14
12 : <cfif right(downloadFilename, 3) eq 'htm'>
13 :
14 : <cfset arr = listToArray (filename, "/",false,true)>
Author: Raymond Camden
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350853
Um... so why did you provide 4 arguments?
----- Excess quoted text cut - see Original Post for more -----
Author: Raymond Camden
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350854
Oh - you were trying to include multichar delimiters. That was added
in CF9. But you aren't using a multichar delim so you don't need it.
----- Excess quoted text cut - see Original Post for more -----
Author: Russ Michaels
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350855
it says 1-3 params, and you have used 4.
http://www.cfquickdocs.com/#ListToArray
check the docs for your cf version, only cf9 support 4 params
On Fri, Apr 27, 2012 at 4:11 PM, Keith McGee
<kpmcgee@frontiernet.net>wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Keith McGee
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350856
Ok that worked, I'm using cf8. If I use a comma or forward slash as a delimiter
doesn't error.
Now if you use a backslash as a delimiter I get this error
Unexpected internal error near index 3 :|\ ^
The error occurred in repositoryView.cfm: line 14
12 : <cfif right(downloadFilename, 3) eq 'htm'>
13 :
14 : <cfset arr = listToArray (filename, "\",true)>
Author: Keith McGee
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350857
Figured it out,
Thank you guys
Author: Brian Thornton
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350858
Remember that Windows and Linux do this differently.
----- Excess quoted text cut - see Original Post for more -----
Author: Claude_Schnéegans
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350859
>>newdir = tests/doc.html
According to the example you give, what you're looking for is not an array but a
substring.
How about
newdir = listGetAt(dir, listLen(dir, "/")-1, "/") & "/" & listLast(dir,
"/")
Author: Christopher Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63879#350861
If your example represents the exact scenario in all cases, I'd probably just use
GetFileFromPath() and GetDirectoryFromPath(), in conjunction with ListLast():
<!--- Where OldDir = Internet/Manuals/tests/doc.html --->
<cfset NewDir =
"#ListLast(GetDirectoryFromPath(OldDir),'/')#/#GetFileFromPath(OldDir)#">
-Christopher
----- Excess quoted text cut - see Original Post for more -----
|
May 18, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||