473,387 Members | 1,510 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,387 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 21050
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.