Solved

CFDirectory reading all files on a website.

Posted on 2006-06-10
4
299 Views
Last Modified: 2013-12-24
Okay.. I have been fiddling with this for a while, and cannot figure out why it only gives me output for one page on my website.

<!---This loop collects all the files into one list--->
<cfset name = "PageIndex">
<cfset FileList = "">
<cfloop list="E:\Inetpub\websitename\public_html\" index="Dir">
  <cfdirectory
   action = "list"
   directory = "#Dir#"
   name = "IndexList"
   filter = "*.html">
  <cfoutput query="IndexList">
    <cfif IndexList.type is "file">
      <cfset FileList = listappend(FileList,Dir&IndexList.name)>
    </cfif>
  </cfoutput>
</cfloop>
<cfloop list="#FileList#" index="ParseFile">
  <CFFILE ACTION="READ" file="#ParseFile#" variable="str">
  <!---Extra the TITLE meta tag--->
  <cfset startstring="<TITLE>">
  <cfset endstring="</TITLE>">
  <cfset parsed="">
  <CFSET start = findnocase(startstring,str)+len(startstring)>
  <cfif start lt 1>
    <cfset start=1>
  </cfif>
  <cfset end = findnocase(endstring,str,start)>
  <cfif end gt start>
    <cfset parsed = trim(MID(str,start,end-start))>
  </cfif>
  <!--Extract the Description meta tag--->
  <cfset startstring2="<meta name=#chr(34)#description#chr(34)# content=#chr(34)#">
  <cfset endstring2="#chr(34)#">
  <cfset parsed2="">
  <CFSET start2 = findnocase(startstring2,str)+len(startstring2)>
  <cfif start2 lt 1>
    <cfset start2=1>
  </cfif>
  <cfset end2 = findnocase(endstring2,str,start2)>
  <cfif end2 gt start2>
    <cfset parsed2 = trim(MID(str,start2,end2-start2))>
  </cfif>
  <!---Extra the BODY meta tag--->
  <cfset startstring3="<BODY">
  <cfset endstring3="</BODY>">
  <cfset parsed3="">
  <CFSET start3 = findnocase(startstring3,str)+len(startstring3)>
  <cfif start3 lt 1>
    <cfset start3=1>
  </cfif>
  <cfset end3 = findnocase(endstring3,str,start3)>
  <cfif end3 gt start3>
    <cfset parsed3 = trim(MID(str,start3,end3-start3))>
  </cfif>
</cfloop>

<cfoutput>#parsed#<BR>
  #parsed2#<BR>
  #parsed3#</cfoutput>
0
Comment
Question by:ServalStudios
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
js_vaughan earned 150 total points
ID: 16879020
Shouldn't your <cfoutput> at the bottom of the page be inside your loop?
0
 
LVL 25

Assisted Solution

by:dgrafx
dgrafx earned 150 total points
ID: 16880910
I modified it for you:
<!---This loop collects all the files into one list--->
<!--- <cfset name = "PageIndex"> Don't need this --->
<cfset FileList = "">
<cfloop list="d:\_web\_cfitools\" index="Dir">
  <cfdirectory
   action = "list"
   directory = "#Dir#"
   name = "IndexList"
   filter = "*.html">
  <cfoutput query="IndexList">
    <cfif IndexList.type is "file">
      <cfset FileList = listappend(FileList,Dir&IndexList.name)>
    </cfif>
  </cfoutput>
</cfloop>
<!--- <cfoutput>#filelist#</cfoutput><CFABORT> --->
<cfloop list="#FileList#" index="ParseFile">
<CFFILE ACTION="READ" file="#ParseFile#" variable="str">
  <!---Extract the TITLE meta tag--->
      <cfset startstring="<TITLE>">
      <cfset endstring="</TITLE>">
      <cfset parsed="">
      <CFSET start = findnocase(startstring,str)>
      <cfif start>
            <cfset start=start+len(startstring)>
            <cfset end = findnocase(endstring,str,start)>
            <cfif end gt start>
            <cfset parsed = trim(MID(str,start,end-start))>
            </cfif>
      </cfif>
  <!--Extract the Description meta tag--->
      <cfset startstring2="<meta name=#chr(34)#description#chr(34)# content=#chr(34)#">
      <cfset endstring2="#chr(34)#">
      <cfset parsed2="">
      <CFSET start2 = findnocase(startstring2,str)>
      <cfif start2>
            <cfset start2=start2+len(startstring2)>      
            <cfset end2 = findnocase(endstring2,str,start2)>
            <cfif end2 gt start2>
            <cfset parsed2 = trim(MID(str,start2,end2-start2))>
            </cfif>
      </cfif>
      <!---Extra the BODY meta tag--->
      <cfset startstring3="<BODY">
      <cfset endstring3="</BODY>">
      <cfset parsed3="">
      <CFSET start3 = findnocase(startstring3,str)>
      <cfif start3>
            <cfset start3=start3+len(startstring3)>      
            <cfset end3 = findnocase(endstring3,str,start3)>
            <cfif end3 gt start3>
            <cfset parsed3 = trim(MID(str,start3,end3-start3))>
            </cfif>
      </cfif>
This is your output here - for your <body> tag you will probably need htmlcodeformat to "see" it or htmleditformat to insert to db<br>
<cfoutput>
#parsed#<BR>
#parsed2#<BR>
#parsed3#<br><br>
</cfoutput>

</cfloop>

0
 
LVL 2

Expert Comment

by:pharmacychoice
ID: 16889618
You are only getting output for one page because of what js_vaughn said.  You need to have your cfoutput in the cfloop or else you are only getting the one record.
0
 
LVL 1

Author Comment

by:ServalStudios
ID: 16891939
Thank you.!
0

Featured Post

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question