Counting files in a folder

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Karnath

    Counting files in a folder

    Is there a way to count how many file exist in a given folder on the server
    using javascript. I realize javascript is client side scripting but i had to
    ask


  • McKirahan

    #2
    Re: Counting files in a folder

    "Steve Karnath" <skarnath(remov e this text)@sbcglobal .net> wrote in message
    news:fguKd.2027 4$wi2.17996@new ssvr11.news.pro digy.com...[color=blue]
    > Is there a way to count how many file exist in a given folder on the[/color]
    server[color=blue]
    > using javascript. I realize javascript is client side scripting but i had[/color]
    to[color=blue]
    > ask[/color]

    Does you Web sever support ASP?


    Comment

    • Steve Karnath

      #3
      Re: Counting files in a folder

      Yes, but I have to restrict my code to javascript. Maybe very little asp
      could be included.

      "McKirahan" <News@McKirahan .com> wrote in message
      news:WuCdnWy-yvRz7GfcRVn-rQ@comcast.com. ..[color=blue]
      > "Steve Karnath" <skarnath(remov e this text)@sbcglobal .net> wrote in[/color]
      message[color=blue]
      > news:fguKd.2027 4$wi2.17996@new ssvr11.news.pro digy.com...[color=green]
      > > Is there a way to count how many file exist in a given folder on the[/color]
      > server[color=green]
      > > using javascript. I realize javascript is client side scripting but i[/color][/color]
      had[color=blue]
      > to[color=green]
      > > ask[/color]
      >
      > Does you Web sever support ASP?
      >
      >[/color]


      Comment

      • McKirahan

        #4
        Re: Counting files in a folder

        "Steve Karnath" <skarnath(remov e this text)@sbcglobal .net> wrote in message
        news:WVvKd.1054 2$2e7.9531@news svr12.news.prod igy.com...[color=blue]
        > Yes, but I have to restrict my code to javascript. Maybe very little asp
        > could be included.
        >
        > "McKirahan" <News@McKirahan .com> wrote in message
        > news:WuCdnWy-yvRz7GfcRVn-rQ@comcast.com. ..[color=green]
        > > "Steve Karnath" <skarnath(remov e this text)@sbcglobal .net> wrote in[/color]
        > message[color=green]
        > > news:fguKd.2027 4$wi2.17996@new ssvr11.news.pro digy.com...[color=darkred]
        > > > Is there a way to count how many file exist in a given folder on the[/color]
        > > server[color=darkred]
        > > > using javascript. I realize javascript is client side scripting but i[/color][/color]
        > had[color=green]
        > > to[color=darkred]
        > > > ask[/color]
        > >
        > > Does you Web sever support ASP?[/color][/color]

        ASP supports JavaScript.

        The question is does your Web server support ASP?

        Is the folder on the server under your web root?

        <% Const cFOL = "your_folde r"
        Dim objFSO
        Set objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
        Dim objGFO
        Set objGFO = objFSO.GetFolde r(Server.MapPat h(cFOL))
        Response.Write( objGFO.Files.Co unt)
        Set objGFO = Nothing
        Set objFSO = Nothing
        %>


        Comment

        • McKirahan

          #5
          Re: Counting files in a folder

          "McKirahan" <News@McKirahan .com> wrote in message
          news:48mdnYB_BJ-WD2fcRVn-vQ@comcast.com. ..

          Here the JScript version:

          <%@ Language="JScri pt" %>
          <% var cFOL = "your_folde r"
          var oFSO = new ActiveXObject(" Scripting.FileS ystemObject")
          var oGFO = oFSO.GetFolder( Server.MapPath( cFOL))
          Response.Write( oGFO.Files.Coun t)
          %>


          Comment

          • SBC Global

            #6
            Re: Counting files in a folder

            Thank you so much for your patience.
            Yes the server supports ASP. The issue is that I am developing files to be
            used on a .NET site where the all the code is compiled and my lack of
            familiarity with .NET. I do not have access to the .NET project environment
            because I am outside their firewall and they do not wish to open a portal to
            allow access. Therefore just to be on the safe side and avoid any
            compatibility issues I am trying to keep my server scripting to a minimum. I
            hope this helps.

            It appears that the code is still asp or is <%@ Language="JScri pt" %> <%
            code here %> telling the javascript code to run at the server?

            "McKirahan" <News@McKirahan .com> wrote in message
            news:iaGdnZto16 3RDmfcRVn-sQ@comcast.com. ..[color=blue]
            > "McKirahan" <News@McKirahan .com> wrote in message
            > news:48mdnYB_BJ-WD2fcRVn-vQ@comcast.com. ..
            >
            > Here the JScript version:
            >
            > <%@ Language="JScri pt" %>
            > <% var cFOL = "your_folde r"
            > var oFSO = new ActiveXObject(" Scripting.FileS ystemObject")
            > var oGFO = oFSO.GetFolder( Server.MapPath( cFOL))
            > Response.Write( oGFO.Files.Coun t)
            > %>
            >
            >[/color]


            Comment

            • McKirahan

              #7
              Re: Counting files in a folder

              "SBC Global" <skarnath.exclu de.this@sbcglob al.net> wrote in message
              news:_EzKd.2520 3$iC4.18434@new ssvr30.news.pro digy.com...[color=blue]
              > Thank you so much for your patience.
              > Yes the server supports ASP. The issue is that I am developing files to be
              > used on a .NET site where the all the code is compiled and my lack of
              > familiarity with .NET. I do not have access to the .NET project[/color]
              environment[color=blue]
              > because I am outside their firewall and they do not wish to open a portal[/color]
              to[color=blue]
              > allow access. Therefore just to be on the safe side and avoid any
              > compatibility issues I am trying to keep my server scripting to a minimum.[/color]
              I[color=blue]
              > hope this helps.
              >
              > It appears that the code is still asp or is <%@ Language="JScri pt" %> <%
              > code here %> telling the javascript code to run at the server?
              >
              > "McKirahan" <News@McKirahan .com> wrote in message
              > news:iaGdnZto16 3RDmfcRVn-sQ@comcast.com. ..[color=green]
              > > "McKirahan" <News@McKirahan .com> wrote in message
              > > news:48mdnYB_BJ-WD2fcRVn-vQ@comcast.com. ..
              > >
              > > Here the JScript version:
              > >
              > > <%@ Language="JScri pt" %>
              > > <% var cFOL = "your_folde r"
              > > var oFSO = new ActiveXObject(" Scripting.FileS ystemObject")
              > > var oGFO = oFSO.GetFolder( Server.MapPath( cFOL))
              > > Response.Write( oGFO.Files.Coun t)
              > > %>[/color][/color]

              You didn't answer my question: "Is the folder on the server under your web
              root?" If the folder is not under your Web root then you (or your
              webmaster) will have to create a virtual folder to point to it.

              Basically, just save my code to a file (say "Files.asp" ); change the value
              for "cFOL"; upload it to your Web server and open (say
              http://{domain}/Files.asp).


              Comment

              • McKirahan

                #8
                Re: Counting files in a folder

                "McKirahan" <News@McKirahan .com> wrote in message
                news:R-SdnQ_TZ7v5VmfcR Vn-ow@comcast.com. ..

                [snip]

                You might want to change it from
                Response.Write( oGFO.Files.Coun t)
                to
                Response.Write( oGFO.Files.Coun t & " files in " & Server.MapPath( cFOL))
                as it will be a little more meaningful for testing.



                Comment

                • SBC Global

                  #9
                  Re: Counting files in a folder

                  Yes my folder is under my web root.

                  "McKirahan" <News@McKirahan .com> wrote in message
                  news:R-SdnQ_TZ7v5VmfcR Vn-ow@comcast.com. ..[color=blue]
                  > "SBC Global" <skarnath.exclu de.this@sbcglob al.net> wrote in message
                  > news:_EzKd.2520 3$iC4.18434@new ssvr30.news.pro digy.com...[color=green]
                  >> Thank you so much for your patience.
                  >> Yes the server supports ASP. The issue is that I am developing files to
                  >> be
                  >> used on a .NET site where the all the code is compiled and my lack of
                  >> familiarity with .NET. I do not have access to the .NET project[/color]
                  > environment[color=green]
                  >> because I am outside their firewall and they do not wish to open a portal[/color]
                  > to[color=green]
                  >> allow access. Therefore just to be on the safe side and avoid any
                  >> compatibility issues I am trying to keep my server scripting to a
                  >> minimum.[/color]
                  > I[color=green]
                  >> hope this helps.
                  >>
                  >> It appears that the code is still asp or is <%@ Language="JScri pt" %> <%
                  >> code here %> telling the javascript code to run at the server?
                  >>
                  >> "McKirahan" <News@McKirahan .com> wrote in message
                  >> news:iaGdnZto16 3RDmfcRVn-sQ@comcast.com. ..[color=darkred]
                  >> > "McKirahan" <News@McKirahan .com> wrote in message
                  >> > news:48mdnYB_BJ-WD2fcRVn-vQ@comcast.com. ..
                  >> >
                  >> > Here the JScript version:
                  >> >
                  >> > <%@ Language="JScri pt" %>
                  >> > <% var cFOL = "your_folde r"
                  >> > var oFSO = new ActiveXObject(" Scripting.FileS ystemObject")
                  >> > var oGFO = oFSO.GetFolder( Server.MapPath( cFOL))
                  >> > Response.Write( oGFO.Files.Coun t)
                  >> > %>[/color][/color]
                  >
                  > You didn't answer my question: "Is the folder on the server under your
                  > web
                  > root?" If the folder is not under your Web root then you (or your
                  > webmaster) will have to create a virtual folder to point to it.
                  >
                  > Basically, just save my code to a file (say "Files.asp" ); change the value
                  > for "cFOL"; upload it to your Web server and open (say
                  > http://{domain}/Files.asp).
                  >
                  >[/color]


                  Comment

                  Working...