Skip to main content
New Participant
October 22, 2010
Question

getting highest numbered filename in directory

  • October 22, 2010
  • 1 reply
  • 813 views

I have a directory of images consecutively numbered.

Is there a way to get the current higest filename - I had been thinking cfdirectory sorted by filename descending limited to 1 result but I don't think cfdirectory allows for that.

Mi-ul

    This topic has been closed for replies.

    1 reply

    Inspiring
    October 22, 2010

    CFDirectory returns a query.  Once you have that, you can use CF's Query-of-a-Query functionality to order and retrieve the data to your hearts content.

    New Participant
    October 22, 2010

    I was hoping to do it in the original function as there are lots of files and it takes a while to run the original query

    Inspiring
    October 22, 2010

    The original function, as you describe it, is cfdirectory.  You only have to do it once.  A Q of Q on the resulting query should be pretty quick, unless you have millions of files to deal with.