Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

<cfdirectory> question

Posted on 2004-08-16
8
Medium Priority
?
742 Views
Last Modified: 2013-12-24
how do I get <cfdirectory> to only display the files in the directory, not the folders?
0
Comment
Question by:JoshDale
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 11816116
Hi JoshDale,
<cfdirectory
   action = "directory action"
   directory = "directory name"
   name = "query name"
   filter = "list filter"
   mode = "permission"
   sort = "sort specification"
   newDirectory = "new directory name">

now what you can do is in filter is make it like *.* or something..
there is nothing specific which can only filter file and not the folder in coldfusion.

so if you use the filter like *.* it will bring all the files but if there is dot in the name of the folder it will bring that too... so you can do like this
*.??? and it will bring the files probably.

Regards,
---Pinal
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11816133
Hi JoshDale,
also there is one good piece of code on the macromedia site which brings all the directory ( just opposite to what you want but still good to know may be we can use it)
<cfdirectory directory="C:/temp" name="dirQuery" action="LIST">
 To list only directories, you must loop over the query returned by cfdirectory and test the type field.
The following example creates both an array of directory names and a query that contains entries for the directories only.
<!--- Get an array of directory names. --->
<cfset dirsArray=arraynew(1)>
<cfset i=1>
<cfloop query="dirQuery">
<cfif dirQuery.type IS "dir">
<cfset dirsArray[i]=dirQuery.name>
<cfset i = i + 1>
</cfif>
</cfloop>
<cfdump var="#dirsArray#">
<br>
<!--- Get all directory information in a query of queries.--->
<cfquery dbtype="query" name="dirsOnly">
SELECT * FROM dirQuery
WHERE TYPE='Dir'
</cfquery>
<cfdump var="#dirsOnly#">

Regards,
---Pinal
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11816140
Hi JoshDale,

Ignore my first messsage. this is the answer to your question.
<cfdirectory directory="C:/temp" name="dirQuery" action="LIST">
 
<!--- Get an array of directory names. --->
<cfset dirsArray=arraynew(1)>
<cfset i=1>
<cfloop query="dirQuery">
<cfif dirQuery.type IS "file">
<cfset dirsArray[i]=dirQuery.name>
<cfset i = i + 1>
</cfif>
</cfloop>
<cfdump var="#dirsArray#">
<br>
<!--- Get all directory information in a query of queries.--->
<cfquery dbtype="query" name="dirsOnly">
SELECT * FROM dirQuery
WHERE TYPE='Dir'
</cfquery>
<cfdump var="#dirsOnly#">



Regards,
---Pinal
0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 21

Expert Comment

by:pinaldave
ID: 11816146
Hi JoshDale, Typo fixed.
<cfdirectory directory="C:/temp" name="dirQuery" action="LIST">
 To list only directories, you must loop over the query returned by cfdirectory and test the type field.
The following example creates both an array of directory names and a query that contains entries for the directories only.
<!--- Get an array of directory names. --->
<cfset dirsArray=arraynew(1)>
<cfset i=1>
<cfloop query="dirQuery">
<cfif dirQuery.type IS "file">
<cfset dirsArray[i]=dirQuery.name>
<cfset i = i + 1>
</cfif>
</cfloop>
<cfdump var="#dirsArray#">
<br>
<!--- Get all directory information in a query of queries.--->
<cfquery dbtype="query" name="dirsOnly">
SELECT * FROM dirQuery
WHERE TYPE='file'
</cfquery>
<cfdump var="#dirsOnly#">


Regards,
---Pinal
0
 
LVL 17

Accepted Solution

by:
anandkp earned 1500 total points
ID: 11817662
<cfdirectory directory="C:/temp" name="dirQuery" action="LIST">
 
<cfoutput query="dirQuery">
      <cfif dirQuery.type IS "file">
            #dirQuery.name#<br>
      </cfif>
</cfoutput>

I dont see the need for the rest of the code [from above]
0
 

Author Comment

by:JoshDale
ID: 11825112
Simple answers get points, thanks.
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11825269
that is the way to go. :)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 11827768
Thou i dont see why it was graded as B ...
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question