468,753 Members | 1,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,753 developers. It's quick & easy.

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 20094
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Simon Wigzell | last post: by
6 posts views Thread by Kenneth Courville | last post: by
1 post views Thread by sasikumar | last post: by
8 posts views Thread by Milsnips | last post: by
3 posts views Thread by ckirchho | last post: by
13 posts views Thread by writeson | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.