Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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>