Counting files in a folder

Discussion in 'Javascript' started by Steve Karnath, Jan 28, 2005.

  1. 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
    Steve Karnath, Jan 28, 2005
    #1
    1. Advertising

  2. Steve Karnath

    McKirahan Guest

    "Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in message
    news:fguKd.20274$...
    > 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


    Does you Web sever support ASP?
    McKirahan, Jan 28, 2005
    #2
    1. Advertising

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

    "McKirahan" <> wrote in message
    news:...
    > "Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in

    message
    > news:fguKd.20274$...
    > > 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

    >
    > Does you Web sever support ASP?
    >
    >
    Steve Karnath, Jan 28, 2005
    #3
  4. Steve Karnath

    McKirahan Guest

    "Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in message
    news:WVvKd.10542$...
    > Yes, but I have to restrict my code to javascript. Maybe very little asp
    > could be included.
    >
    > "McKirahan" <> wrote in message
    > news:...
    > > "Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in

    > message
    > > news:fguKd.20274$...
    > > > 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

    > >
    > > Does you Web sever support ASP?


    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_folder"
    Dim objFSO
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Dim objGFO
    Set objGFO = objFSO.GetFolder(Server.MapPath(cFOL))
    Response.Write(objGFO.Files.Count)
    Set objGFO = Nothing
    Set objFSO = Nothing
    %>
    McKirahan, Jan 28, 2005
    #4
  5. Steve Karnath

    McKirahan Guest

    "McKirahan" <> wrote in message
    news:...

    Here the JScript version:

    <%@ Language="JScript" %>
    <% var cFOL = "your_folder"
    var oFSO = new ActiveXObject("Scripting.FileSystemObject")
    var oGFO = oFSO.GetFolder(Server.MapPath(cFOL))
    Response.Write(oGFO.Files.Count)
    %>
    McKirahan, Jan 28, 2005
    #5
  6. Steve Karnath

    SBC Global Guest

    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="JScript" %> <%
    code here %> telling the javascript code to run at the server?

    "McKirahan" <> wrote in message
    news:...
    > "McKirahan" <> wrote in message
    > news:...
    >
    > Here the JScript version:
    >
    > <%@ Language="JScript" %>
    > <% var cFOL = "your_folder"
    > var oFSO = new ActiveXObject("Scripting.FileSystemObject")
    > var oGFO = oFSO.GetFolder(Server.MapPath(cFOL))
    > Response.Write(oGFO.Files.Count)
    > %>
    >
    >
    SBC Global, Jan 28, 2005
    #6
  7. Steve Karnath

    McKirahan Guest

    "SBC Global" <> wrote in message
    news:_EzKd.25203$...
    > 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="JScript" %> <%
    > code here %> telling the javascript code to run at the server?
    >
    > "McKirahan" <> wrote in message
    > news:...
    > > "McKirahan" <> wrote in message
    > > news:...
    > >
    > > Here the JScript version:
    > >
    > > <%@ Language="JScript" %>
    > > <% var cFOL = "your_folder"
    > > var oFSO = new ActiveXObject("Scripting.FileSystemObject")
    > > var oGFO = oFSO.GetFolder(Server.MapPath(cFOL))
    > > Response.Write(oGFO.Files.Count)
    > > %>


    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).
    McKirahan, Jan 28, 2005
    #7
  8. Steve Karnath

    McKirahan Guest

    "McKirahan" <> wrote in message
    news:...

    [snip]

    You might want to change it from
    Response.Write(oGFO.Files.Count)
    to
    Response.Write(oGFO.Files.Count & " files in " & Server.MapPath(cFOL))
    as it will be a little more meaningful for testing.
    McKirahan, Jan 28, 2005
    #8
  9. Steve Karnath

    SBC Global Guest

    Yes my folder is under my web root.

    "McKirahan" <> wrote in message
    news:...
    > "SBC Global" <> wrote in message
    > news:_EzKd.25203$...
    >> 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="JScript" %> <%
    >> code here %> telling the javascript code to run at the server?
    >>
    >> "McKirahan" <> wrote in message
    >> news:...
    >> > "McKirahan" <> wrote in message
    >> > news:...
    >> >
    >> > Here the JScript version:
    >> >
    >> > <%@ Language="JScript" %>
    >> > <% var cFOL = "your_folder"
    >> > var oFSO = new ActiveXObject("Scripting.FileSystemObject")
    >> > var oGFO = oFSO.GetFolder(Server.MapPath(cFOL))
    >> > Response.Write(oGFO.Files.Count)
    >> > %>

    >
    > 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).
    >
    >
    SBC Global, Jan 28, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    3
    Views:
    2,923
    Alvin Bruney
    Oct 16, 2003
  2. William LaMartin

    _vti_cnf folder in the bin folder-- a problem?

    William LaMartin, Nov 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,688
    Oliver
    Nov 10, 2003
  3. Replies:
    7
    Views:
    394
    Gabriel Genellina
    Sep 25, 2007
  4. AAaron123
    Replies:
    3
    Views:
    568
    AAaron123
    Nov 4, 2008
  5. edwardfredriks

    counting up instead of counting down

    edwardfredriks, Sep 6, 2005, in forum: Javascript
    Replies:
    6
    Views:
    197
    Dr John Stockton
    Sep 7, 2005
Loading...

Share This Page