Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CFDirectory reading all files on a website.

Posted on 2006-06-10
4
Medium Priority
?
309 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 600 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 600 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

618 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