Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFDirectory -> increment

New Here ,
Nov 28, 2011 Nov 28, 2011

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

452
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2011 Nov 28, 2011
LATEST

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources