By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

Counting files in a folder

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
"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

P: n/a
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.