Problems with directoryList() function

According to both the Lucee and ACF docs, the arguments to directoryList are these:

DirectoryList( path [, recurse [, listInfo [, filter [, sort [, type ] ] ] ] ] )


  • When I pass type (I want directories only), I get the error “too many Attributes in function [DIRECTORYLIST]”
  • The sort argument doesn’t seem to do anything; listing is by name ascending, even if I pass “datelastmodified dec”, which is what I actually want.

Am I missing something obvious, or should I file a bug?

I’m running a CommandBox instance of Lucee

Hi Dave

  1. Support for the type argument was only added in Lucee 5:

  1. The sort argument seems to work for me on both and
path = getDirectoryFromPath( getCurrentTemplatePath() );
x = DirectoryList( path, false, "query", "*", "dateLastModified DESC" );
dump( x );

There’s a typo in the string you posted though: "“datelastmodified dec”

1 Like

I’ve submitted a change to CFDocs to flag that the type argument requires Lucee 5.

Thanks for your reply Julian.

Upgraded to latest Lucee available via CommandBox, and now the type argument works, thanks for the heads-up.

However, the ‘dec’ part of the sort argument is still ignored, results are always ascending. That’s with this code:

directoryList(_path, 0, "query", "", "dateLastModified dec", "dir")

This is Lucee on Win 7 Pro 64. What am I missing here?

You need DESC not DEC.

1 Like