Determining number of files in folder using javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • prashant

    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
  • Randy Webb

    #2
    Re: Determining number of files in folder using javascript

    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.javas cript FAQ - http://jibbering.com/faq/index.html
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • stannyc@gmail.com

      #3
      Re: Determining number of files in folder using javascript

      On Dec 23, 11:18 am, prashant <b.prash...@gma il.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

      Comment

      • My Pet Programmer

        #4
        Re: Determining number of files in folder using javascript

        stannyc@gmail.c om 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!

        Comment

        • My Pet Programmer

          #5
          Re: Determining number of files in folder using javascript

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

          Um, silly. Not sully.

          Comment

          • Dr J R Stockton

            #6
            Re: Determining number of files in folder using javascript

            In comp.lang.javas cript message <wcWdnZZ_5cafW_ PaRVn_vwA@gigan ews.com>,
            Sun, 23 Dec 2007 15:33:07, Randy Webb <HikksNotAtHome @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.publi c.scripting.jsc ript 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.demo n.co.uk/news-use.htm: about usage of News.
            No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.

            Comment

            • prashant

              #7
              Re: Determining number of files in folder using javascript

              On Dec 23 2007, 10:40 pm, "stan...@gmail. com" <stan...@gmail. com>
              wrote:
              On Dec 23, 11:18 am, prashant <b.prash...@gma il.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 ?

              Comment

              • Anthony Levensalor

                #8
                Re: Determining number of files in folder using 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.

                ~A!


                --
                anthony at my pet programmer dot com

                Comment

                • Evertjan.

                  #9
                  Re: Determining number of files in folder using javascript

                  Anthony Levensalor wrote on 07 jan 2008 in comp.lang.javas cript:
                  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)

                  Comment

                  • Thomas 'PointedEars' Lahn

                    #10
                    Re: Determining number of files in folder using javascript

                    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>

                    Comment

                    • Thomas 'PointedEars' Lahn

                      #11
                      Re: Determining number of files in folder using javascript

                      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>

                      Comment

                      • Anthony Levensalor

                        #12
                        Re: Determining number of files in folder using javascript

                        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

                        Comment

                        • Randy Webb

                          #13
                          Re: Determining number of files in folder using javascript

                          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.javas cript FAQ - http://jibbering.com/faq/index.html
                          Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                          Comment

                          • Anthony Levensalor

                            #14
                            Re: Determining number of files in folder using javascript

                            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

                            Comment

                            • prashant

                              #15
                              Re: Determining number of files in folder using javascript

                              On Jan 7, 7:21 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.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 imagefileslocat ed?
                              >
                              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

                              Comment

                              Working...