473,238 Members | 1,799 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,238 software developers and data experts.

Determining number of files in folder using javascript

hello,
I am looking to determine the number of image files in a
folder so that I could create a dynamic table accordingly. For this i
need a method to identify the number of files in a folder. Is there
any way i could estimate this so that i could determine the size of an
array to create my tables

regards
Prashant
Dec 23 '07 #1
14 21013
prashant said the following on 12/23/2007 11:18 AM:
hello,
I am looking to determine the number of image files in a
folder so that I could create a dynamic table accordingly. For this i
need a method to identify the number of files in a folder.
Client-side JS can't do that. It is trivial in any server side language
though.
Is there any way i could estimate this so that i could determine
the size of an array to create my tables
Huh? Nothing in that makes any sense.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 23 '07 #2
On Dec 23, 11:18*am, prashant <b.prash...@gmail.comwrote:
hello,
* * * * * I am looking to determine the number of image files ina
folder so that I could create a dynamic table accordingly. For this i
need a method to identify the number of files in a folder. Is there
any way i could estimate this so that i could determine the size of an
array to create my tables

regards
Prashant
In Javascript, you never have to dimension an array before you use
it. You can just do something like this:

var imgs = some code that grabs the images
var imgArray = []; / create an empty array

for (var t=0; t=imgs[t]; t++)
imgArray.push(t);

and your array will be populated
Dec 23 '07 #3
st*****@gmail.com said:
>
In Javascript, you never have to dimension an array before you use
it. You can just do something like this:

var imgs = some code that grabs the images
var imgArray = []; / create an empty array

for (var t=0; t=imgs[t]; t++)
imgArray.push(t);

and your array will be populated
Hey, thanks for that. I was assigning new elements with:

imgArray[imgArray.length] = t;

I knew it was inefficient, just never thought to use push, I suppose. I
feel sully now.

Thanks a ton!

~A!
Dec 23 '07 #4
I knew it was inefficient, just never thought to use push, I suppose. I
feel sully now.

Um, silly. Not sully.
Dec 23 '07 #5
In comp.lang.javascript message <wc*********************@giganews.com>,
Sun, 23 Dec 2007 15:33:07, Randy Webb <Hi************@aol.composted:
>prashant said the following on 12/23/2007 11:18 AM:
> I am looking to determine the number of image files in a
folder so that I could create a dynamic table accordingly. For this i
need a method to identify the number of files in a folder.

Client-side JS can't do that.
...
Depends on what client-side is thought to mean. Javascript running in
Windows under WSH should be able to do what is needed, and an HTA may
too.

For that environment, microsoft.public.scripting.jscript should be
better.

--
(c) John Stockton, Surrey, UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Dec 24 '07 #6
On Dec 23 2007, 10:40 pm, "stan...@gmail.com" <stan...@gmail.com>
wrote:
On Dec 23, 11:18 am, prashant <b.prash...@gmail.comwrote:
hello,
I am looking to determine the number of image files in a
folder so that I could create a dynamic table accordingly. For this i
need a method to identify the number of files in a folder. Is there
any way i could estimate this so that i could determine the size of an
array to create my tables
regards
Prashant

In Javascript, you never have to dimension an array before you use
it. You can just do something like this:

var imgs = some code that grabs the images
var imgArray = []; / create an empty array

for (var t=0; t=imgs[t]; t++)
imgArray.push(t);

and your array will be populated
Thanks for the idea...
But could you give me an instance how I could get each image file from
a folder ?

Jan 7 '08 #7
prashant said:
Thanks for the idea...
But could you give me an instance how I could get each image file from
a folder ?
Use a server-side scripting language to write the values of the files in
a given folder. What you're asking is not meant to be accomplished via
Javascript.

~A!
--
anthony at my pet programmer dot com
Jan 7 '08 #8
Anthony Levensalor wrote on 07 jan 2008 in comp.lang.javascript:
prashant said:
>Thanks for the idea...
But could you give me an instance how I could get each image file from
a folder ?

Use a server-side scripting language to write the values of the files in
a given folder. What you're asking is not meant to be accomplished via
Javascript.
But for Javascript as a serverside scripting language.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 7 '08 #9
Anthony Levensalor wrote:
prashant said:
>Thanks for the idea...
But could you give me an instance how I could get each image file from
a folder ?

Use a server-side scripting language to write the values of the
files in a given folder.
I don't think this statement makes any sense.
What you're asking is not meant to be accomplished via Javascript.
I don't think so. Furthermore, your statement as it is implies that
JavaScript (and ECMAScript implementations in general) are scripting
languages that can be used only on the client, whereas the opposite
is true.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jan 7 '08 #10
prashant wrote:
But could you give me an instance how I could get each image file from a
folder ?
Probably. Where is the script and where are the image files located?
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jan 7 '08 #11
Thomas 'PointedEars' Lahn said:
I don't think so. Furthermore, your statement as it is implies that
JavaScript (and ECMAScript implementations in general) are scripting
languages that can be used only on the client, whereas the opposite
is true.
Such an implication was not my intent. In almost all of the questions
asked here, however, Javascript is being used on the client side, and I
was operating under the assumption that the OP was using it that way. If
I caused any confusion, then I apologize.

~A!

--
anthony at my pet programmer dot com
Jan 7 '08 #12
Anthony Levensalor said the following on 1/7/2008 2:38 PM:
Thomas 'PointedEars' Lahn said:
>I don't think so. Furthermore, your statement as it is implies that
JavaScript (and ECMAScript implementations in general) are scripting
languages that can be used only on the client, whereas the opposite
is true.

Such an implication was not my intent. In almost all of the questions
asked here, however, Javascript is being used on the client side, and I
was operating under the assumption that the OP was using it that way.
It is the default assumption, unless stated otherwise, that any question
referring to script is referring to client side scripting. Don't let
Thomas' pedantic behavior distract you.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 7 '08 #13
Randy Webb said:
It is the default assumption, unless stated otherwise, that any question
referring to script is referring to client side scripting. Don't let
Thomas' pedantic behavior distract you.
I'm a little gun-shy as it is about posting, so that helps quite a bit.
Thanks, Randy.

--
anthony at my pet programmer dot com
Jan 7 '08 #14
On Jan 7, 7:21 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
prashant wrote:
But could you give me an instance how I could get each image file from a
folder ?

Probably. Where is the script and where are the imagefileslocated?

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
The images should be located on a server. The javascript would be on
the client side. As Ive seen from the replies, this should be more
easily accomplished by a server side scripting. But if you have a
simple way to get the images from a folder on the server, please let
me know.

regards
prashant
Jan 15 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simon Wigzell | last post by:
I am adapting a javascript pulldown menu system to my dynamic website generator - the arrays that hold the menu items information are read from a database and will be different for different users...
7
by: Jean-David Beyer | last post by:
I have six hard drives (4 SCSI and 2 EIDE) on my main machine with parts of a database on each drive. The main index is on one SCSI drive all to itself. The main data are on the other three SCSI...
6
by: Kenneth Courville | last post by:
Hello, I'm looking for assistance with the Access object model. I know this is VB, but I'm building an Office Add-using C# directed at Access 2002. I'm literate in VB, so you can reply in VB... I...
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
1
by: sasikumar | last post by:
i have created a new folder inside project(say update for storing update files for software) how can i get total number of files in that folder.what will be full path for accessing that...
8
by: Milsnips | last post by:
hi there, i'm currently using the following line: <script language="javascript" type="text/javascript" src="../scripts/timer.js"></script> but i want to do the following, as the script...
3
by: ckirchho | last post by:
Hallo, my task is to establish some kind of full text file search in Javascript. The files and it's contents are fixed, the HTML/JavaScript pages lie offline on a server. As far as Javascript...
13
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.