Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Counting files in a folder

Reply
Thread Tools

Counting files in a folder

 
 
Steve Karnath
Guest
Posts: n/a
 
      01-28-2005
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


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      01-28-2005
"Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in message
news:fguKd.20274$(E-Mail Removed). 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?


 
Reply With Quote
 
 
 
 
Steve Karnath
Guest
Posts: n/a
 
      01-28-2005
Yes, but I have to restrict my code to javascript. Maybe very little asp
could be included.

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

message
> news:fguKd.20274$(E-Mail Removed). 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?
>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-28-2005
"Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in message
news:WVvKd.10542$(E-Mail Removed) om...
> Yes, but I have to restrict my code to javascript. Maybe very little asp
> could be included.
>
> "McKirahan" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > "Steve Karnath" <skarnath(remove this text)@sbcglobal.net> wrote in

> message
> > news:fguKd.20274$(E-Mail Removed). 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
%>


 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-28-2005
"McKirahan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

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


 
Reply With Quote
 
SBC Global
Guest
Posts: n/a
 
      01-28-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "McKirahan" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> 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)
> %>
>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-28-2005
"SBC Global" <(E-Mail Removed)> wrote in message
news:_EzKd.25203$(E-Mail Removed). 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > "McKirahan" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >
> > 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).


 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-28-2005
"McKirahan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

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



 
Reply With Quote
 
SBC Global
Guest
Posts: n/a
 
      01-28-2005
Yes my folder is under my web root.

"McKirahan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "SBC Global" <(E-Mail Removed)> wrote in message
> news:_EzKd.25203$(E-Mail Removed). 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > "McKirahan" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >
>> > 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).
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
32bit Program installed to the Program Files folder and not the PFx86 folder murdock69u@gmail.com Windows 64bit 1 04-30-2009 01:30 PM
TRying to import files from my folder not pythons lib folder tedpottel@gmail.com Python 7 09-25-2007 02:36 AM
unable to create the folder "new folder: no new files Cindy Stuart Computer Support 5 06-03-2007 07:32 AM
counting up instead of counting down edwardfredriks Javascript 6 09-07-2005 03:30 PM
Can't copy Outlook Ex files in folder to Windows folder? Paul - xxx Computer Support 2 08-20-2003 03:06 AM



Advertisments