Loop Over a File in Coldfusion

Here is a little code of looping over a file in coldfusion using CFLOOP.

Lets have a look.

  • Loop over a file – lines.

[code:cf]

<cfloop file="YourFilePath" index="line">
Your code goes on here…
</cfloop>

[/code]

  • Loop over a file – characters. You can specify number of characters to loop over.

[code:cf]

<cfloop file="YourFilePath" index="chars" characters="6">
Your code goes on here..
</cfloop>

[/code]