Here is what I am trying to do: I want list files in downloads folder. Downloads folder ahe further sub-folder. So what I want to do is, list files in each subfolder seperately. Here is the code I am using to do this: <td headers="update_id"><a href="xyz">#request_id#</a></td> <td headers="title">#title#</td> <td headers="date">#date_submitted#</td> <td headers="name">#fname# #lname#</td> <td headers="completed">#isCompleted#</td> <td headers="email">#email#</td> <cfif hasAttachements eq "Y"> <td headers="Attachments"> <cfset dir_name="xyz\downloads\"> <cfset dir_name= dir_name & title & date_submitted & "\"> <cfset original_link_name= "xyz/downloads/" & title & date_submitted & "\"> <cfdirectory action="list" directory=#dir_name# name="dirList#title#"> <cfloop query="dirList#title#"> <cfset link_name = original_link_name & #name#> <cfif name neq "." OR name neq ".."> <cfoutput><a href="#link_name#">#name# </a><br /></cfoutput> </cfif> </cfloop> </td> </cfif> </tr> Actually the problem is: Suppose 1st directory has xxx.txt and yyy.txt It outputs them properly. Suppose 2nd has vvv.txt Then in this case it outputs as vvv.txt and vvv.txt where as it should print only once. Suppose 3rd one has abc.txt then it prints same file 3 times. SO basically it prints files correctly just that it prints them number equal to folder that I have browsed. I think I need something to actually reset cfloop so that it start again from start. Does any one know??
Unless you're running an old verison of CF, it's easier to use cfdirectory recurse="true". It will recurse all subdirectories and return all files, in all subdirectories, in 1 query.