Is it possible to somehow exclude files using cfdirectory?

When using cfdirectory, how can I exclude all cfm files and list all the others without specifying file extensions for all the files that I want to see, or exclude a specific file, such as index.html, without requesting a request?

I am looking for something like the following, pay attention to the filter attribute.

<cfdirectory directory="#ExpandPath('./')#" action="list" name="qryFiles" filter="!index.html" sort="name ASC" listinfo="name">

or

<cfdirectory directory="#ExpandPath('./')#" action="list" name="qryFiles" filter="!*.cfm" sort="name ASC" listinfo="name">
+5
source share
5 answers

, . : cfdirectory, , EXLCUDE , "." , ".svn" ".git". , .

, :

<cfloop query="mydir">
  <cfif left(name, 1) neq ".">
    <!--- do some code --->
  </cfif>
</cfloop>

. , QoQ, , , .

, , , cfdirectory, , .

+6

, cfdirectory. , , DOS (* ?).

, , cfquery.

<cfquery name="qryFiles" dbtype="query">
    SELECT * FROM qryFiles
    WHERE name not like '%.cfm'
</cfquery>
+6

, CF, (, ), . .

+2

, java .

CreateObject("java", "java.io.File");  

..

Personally, I think you would be better off just using a query query.

+1
source

I sure that! the operator will not work in the filter parameter.

I see no way to get around a query request or loop through a query using cfoutput / cfloop, and then check the value of each file name with the cfif / cfcase statement to see if you want it to show up.

0
source

All Articles