472,139 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 software developers and data experts.

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
Jul 23 '05 #1
8 4782
"Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in message
news:fg*******************@newssvr11.news.prodigy. com...
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?
Jul 23 '05 #2
Yes, but I have to restrict my code to javascript. Maybe very little asp
could be included.

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Wu********************@comcast.com...
"Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in message news:fg*******************@newssvr11.news.prodigy. com...
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?

Jul 23 '05 #3
"Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in message
news:WV******************@newssvr12.news.prodigy.c om...
Yes, but I have to restrict my code to javascript. Maybe very little asp
could be included.

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

message
news:fg*******************@newssvr11.news.prodigy. com...
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
%>
Jul 23 '05 #4
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:48********************@comcast.com...

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)
%>
Jul 23 '05 #5
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" <Ne**@McKirahan.com> wrote in message
news:ia********************@comcast.com...
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:48********************@comcast.com...

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)
%>

Jul 23 '05 #6
"SBC Global" <sk*******************@sbcglobal.net> wrote in message
news:_E*******************@newssvr30.news.prodigy. com...
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" <Ne**@McKirahan.com> wrote in message
news:ia********************@comcast.com...
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:48********************@comcast.com...

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).
Jul 23 '05 #7
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:R-********************@comcast.com...

[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.

Jul 23 '05 #8
Yes my folder is under my web root.

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:R-********************@comcast.com...
"SBC Global" <sk*******************@sbcglobal.net> wrote in message
news:_E*******************@newssvr30.news.prodigy. com...
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" <Ne**@McKirahan.com> wrote in message
news:ia********************@comcast.com...
> "McKirahan" <Ne**@McKirahan.com> wrote in message
> news:48********************@comcast.com...
>
> 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).

Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ron Nolan | last post: by
18 posts views Thread by Conrad F | last post: by
2 posts views Thread by Glen | last post: by
2 posts views Thread by jmaillet | last post: by
2 posts views Thread by David C | last post: by
4 posts views Thread by frizzle | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.