Skip to main content
Participant
November 28, 2011
Question

CFDirectory -> increment

  • November 28, 2011
  • 1 reply
  • 467 views

Is anyone able to give me a sample script, such that if it finds an existing file, I can create a file with an incremented number.

Not sure exactly how to phrase the question but here's an example:

The following files exist:

file01.dat

file02.dat

file03.dat

I want to now create the next file in sequence based on the existance of the above files:

file04.dat

Can someone provide some sample code as to how can I use cfdirectory to come up with "file04.dat"?

Thanks

    This topic has been closed for replies.

    1 reply

    TheStig99Author
    Participant
    November 28, 2011

    Ok I resolved it myself, this seems to work:

    <cfdirectory directory="#app.folder#" action="list" filter="file*.dat" listinfo="name" name="dirQuery">

    <cfoutput>#NumberFormat(dirQuery.RecordCount + 1,"0_")#</cfoutput>