473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 4929
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ron Nolan | last post by:
Re: Access 2000 How can I loop through a folder on the user's hard drive, and check to see if it is an .mdb file. If it is an .mdb, do some stuff, else go to the next filename? Can this be...
18
by: Conrad F | last post by:
Hello all, I am waiting for receipt of files in a directory. I use the FileSystemWatcher to detect when files arrive in said folder. I need to read the data from these files ASAP but the files...
2
by: Glen | last post by:
As I understand it, when the first page of an application is accessed, all ASPX/ASCX/etc. files in the same folder are compiled using the JIT compiler. Is there a way to turn this feature off? ...
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
2
by: jmaillet | last post by:
Is there a way to count files in a specific folder using ONLY javascript? I am creating a site for the intranet at work that will post weekly reports. Users will drop weekly reports in a folder...
14
by: Dan | last post by:
Is this discouraged?: for line in open(filename): <do something with line> That is, should I do this instead?: fileptr = open(filename) for line in fileptr: <do something with line>
2
by: David C | last post by:
I have an ASP.Net web site that does some file system folder access. One of the things I am doing is counting the # of files in a passed directory to determine if I show or hide something on the...
4
by: frizzle | last post by:
Hi there, I have a function to create an array of all files in a certain folder, so i can display the structure. The actual function is below the message, as is an example of its output. As...
15
by: Andy B | last post by:
I need to count files in a certain directory that has the string -Contract Template.xml at the end of it. How would I do this?
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.