Multiple loops. Please help. Desperate.

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

    #1

    Multiple loops. Please help. Desperate.

    I have had this post up here when i was trying to figure out how to
    make leading zeros and have been able to fudge that to work. I am now
    have trouble getting the loop that makes the folders to start fresh
    after the .jpg section of the move images code. this will be
    essential to make the whole thing work. Please help. Even if you
    just write out the solution. I am beggin. I am desperate. Please
    help.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>File transfer</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    </head>

    <body>
    <table width="75%" border="0">
    <tr>
    <td>
    <script language='javas cript'>

    folder = window.prompt(' starting folder','defaul t');
    picnumber = window.prompt(' pictures taken?','defaul t');
    f2 = parseFloat(fold er);
    p2 = parseFloat(picn umber);


    /*adds the amount of photos taken to the starting folder number to
    ensure proper amount of folders are present and tells user what the
    starting folder and end folders are*/

    varAdd = f2+p2-1;
    varImg = p2;
    var9 = '000';
    var99 = '00';
    var999 = '0';
    var9999 = '0000';
    document.write( 'Starting folder is <b>',f2,'</b><br>');
    document.write( 'Ending folder should be <b>' + varAdd +
    '</b><br><br>');

    /*Commands used to bring system to standard for file transfer*/

    document.write( 'cd..<br>')
    document.write( 'cd documents and settings\\chris topher
    neu\\desktop<br >')
    document.write( 'mkdir transfer<br>')
    document.write( 'cd transfer<br>')

    /*copies files from smartmedia to transfer folder*/

    document.write( 'copy d:\\dcim\\100_f uji\\*.jpg<br>' )

    /*calculates and writes proper amount of folders in the transfer
    folder via the "mkdir" command to properly transfer files*/

    for (count1=f2;coun t1<=varAdd;coun t1++)
    if (count1 <=9)
    document.write( 'mkdir',var9999 + count1 +'<br>');
    else if (count1 <=99)
    document.write( 'mkdir',var9 + count1 +'<br>');
    else if (count1 <=999)
    document.write( 'mkdir',var99 + count1 +'<br>');
    else if (count1 <=9999)
    document.write( 'mkdir',var999 + count1 +'<br>');
    else
    document.write( 'mkdir' + count1 +'<br>');


    /*moves pictures into proper folders. This is where the problem is.
    I need to put the count that produced the folders after .jpg and have
    it start fresh and continue till the move images count is done.
    Perhaps this can be done with a function but i can not figure it out.
    I can not figure out functions at all actually. :)*/

    for (count=1;count< =varImg;count++ )
    if (count <=9)
    document.write( 'move dscf',var9 + count +'.jpg <br>');
    else if (count <=99)
    document.write( 'move dscf',var99 + count +'.jpg <br>');
    else if (count <=999)
    document.write( 'move dscf',var999 + count +'.jpg <br>');
    else
    document.write( 'move dscf' + count +'.jpg <br>');

    </script>
    </td>
    </tr>
    </table>
    </body>
    </html>
  • McKirahan

    #2
    Re: Multiple loops. Please help. Desperate.

    "Tank" <isa16w16w@yaho o.com> wrote in message
    news:991bf7ca.0 402101837.7c1ae 230@posting.goo gle.com...[color=blue]
    > I have had this post up here when i was trying to figure out how to
    > make leading zeros and have been able to fudge that to work. I am now
    > have trouble getting the loop that makes the folders to start fresh
    > after the .jpg section of the move images code. this will be
    > essential to make the whole thing work. Please help. Even if you
    > just write out the solution. I am beggin. I am desperate. Please
    > help.
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    > <html>
    > <head>
    > <title>File transfer</title>
    > <meta http-equiv="Content-Type" content="text/html;
    > charset=iso-8859-1">
    > </head>
    >
    > <body>
    > <table width="75%" border="0">
    > <tr>
    > <td>
    > <script language='javas cript'>
    >
    > folder = window.prompt(' starting folder','defaul t');
    > picnumber = window.prompt(' pictures taken?','defaul t');
    > f2 = parseFloat(fold er);
    > p2 = parseFloat(picn umber);
    >
    >
    > /*adds the amount of photos taken to the starting folder number to
    > ensure proper amount of folders are present and tells user what the
    > starting folder and end folders are*/
    >
    > varAdd = f2+p2-1;
    > varImg = p2;
    > var9 = '000';
    > var99 = '00';
    > var999 = '0';
    > var9999 = '0000';
    > document.write( 'Starting folder is <b>',f2,'</b><br>');
    > document.write( 'Ending folder should be <b>' + varAdd +
    > '</b><br><br>');
    >
    > /*Commands used to bring system to standard for file transfer*/
    >
    > document.write( 'cd..<br>')
    > document.write( 'cd documents and settings\\chris topher
    > neu\\desktop<br >')
    > document.write( 'mkdir transfer<br>')
    > document.write( 'cd transfer<br>')
    >
    > /*copies files from smartmedia to transfer folder*/
    >
    > document.write( 'copy d:\\dcim\\100_f uji\\*.jpg<br>' )
    >
    > /*calculates and writes proper amount of folders in the transfer
    > folder via the "mkdir" command to properly transfer files*/
    >
    > for (count1=f2;coun t1<=varAdd;coun t1++)
    > if (count1 <=9)
    > document.write( 'mkdir',var9999 + count1 +'<br>');
    > else if (count1 <=99)
    > document.write( 'mkdir',var9 + count1 +'<br>');
    > else if (count1 <=999)
    > document.write( 'mkdir',var99 + count1 +'<br>');
    > else if (count1 <=9999)
    > document.write( 'mkdir',var999 + count1 +'<br>');
    > else
    > document.write( 'mkdir' + count1 +'<br>');
    >
    >
    > /*moves pictures into proper folders. This is where the problem is.
    > I need to put the count that produced the folders after .jpg and have
    > it start fresh and continue till the move images count is done.
    > Perhaps this can be done with a function but i can not figure it out.
    > I can not figure out functions at all actually. :)*/
    >
    > for (count=1;count< =varImg;count++ )
    > if (count <=9)
    > document.write( 'move dscf',var9 + count +'.jpg <br>');
    > else if (count <=99)
    > document.write( 'move dscf',var99 + count +'.jpg <br>');
    > else if (count <=999)
    > document.write( 'move dscf',var999 + count +'.jpg <br>');
    > else
    > document.write( 'move dscf' + count +'.jpg <br>');
    >
    > </script>
    > </td>
    > </tr>
    > </table>
    > </body>
    > </html>[/color]

    Running your code generates a page with:

    Starting folder is 2
    Ending folder should be 4

    cd..
    cd documents and settings\christ opherneu\deskto p
    mkdir transfer
    cd transfer
    copy d:\dcim\100_fuj i\*.jpg
    mkdir00002
    mkdir00003
    mkdir00004
    move dscf0001.jpg
    move dscf0002.jpg
    move dscf0003.jpg

    Note that there is no space between "mkdir" and the "0000" prefix folders.
    Also, you may want "cd\" instead of "cd..".


    What are you trying to do?
    Is it to create a batch file that will copy images?
    If so, why are you using HTML?


    I would suggest using WSH (Windows Script Host)
    written in either JavaScript or VBScript.


    Start with a clear statement of the task; such as:

    I want to first copy all JPG images from
    d:\dcim\100_fuj i\
    into a user specified range of subfolders under
    c:\documents and settings\christ opherneu\deskto p\transfer\
    etc.


    Comment

    • Christopher N

      #3
      Re: Multiple loops. Please help. Desperate.



      Thanks for the response.

      if you do not mind readin a minute i will explain the background of the
      script to better help understand the result.

      Here is the scenario:

      Where i work we have many roving photographers. each of these
      photographers has a memory card that can hold x number of photos. When
      they take a photo of someone they give them a numbered card. The
      photographer copies 1 image to one folder and then 2nd image to second
      folder and so forth. These folders have the same number as the
      corresponding card the customer recieved.

      The customer then can go to a kiosk and enter card number onto the
      screen. The corresponding folder is accessed and the photo is shown.
      The problem with this is if the photographer messes up and puts a
      picture in the wrong folder then the whole system is thrown off and we
      have to try to find the problem and fix it. if they do it twice then we
      are really up the creek.

      The script i wrote is my attempt to remove the human factor. The reason
      it is javascript in html is because that is the only thing that i have
      any remote experience in.

      You said it exactly.

      I want to first copy all JPG images from
      d:\dcim\100_fuj i\
      into the folder
      c:\documents and settings\christ opherneu\deskto p\transfer\

      Then create user definde subfolders within
      c:\documents and settings\christ opherneu\deskto p\transfer\

      then move lowest numbered image into lowest numbered subfolder within
      c:\documents and settings\christ opherneu\deskto p\transfer\

      The only constant in this whole little mess is the image name.
      dscf0001.jpg being the lowest and going up from there.

      once the javascript finishes the photographer will just copy the text
      and paste it in the command prompt. The instructions should go from
      there.

      here is the code with the changes you suggested. I kew about them but
      forgot to do it. Thanks for reminding me! :) Thanks in advance for
      any help you can provide.

      Chris


      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">[color=blue]
      > <html>
      > <head>
      > <title>File transfer</title>
      > <meta http-equiv="Content-Type" content="text/html;
      > charset=iso-8859-1">
      > </head>
      >
      > <body>
      > <table width="75%" border="0">
      > <tr>
      > <td>
      > <script language='javas cript'>
      >
      > folder = window.prompt(' starting folder','defaul t');
      > picnumber = window.prompt(' pictures taken?','defaul t');
      > f2 = parseFloat(fold er);
      > p2 = parseFloat(picn umber);
      >
      >
      > /*adds the amount of photos taken to the starting folder number to
      > ensure proper amount of folders are present and tells user what the
      > starting folder and end folders are*/
      >
      > varAdd = f2+p2-1;
      > varImg = p2;
      > var9 = '000';
      > var99 = '00';
      > var999 = '0';
      > var9999 = '0000';
      > document.write( 'Starting folder is <b>',f2,'</b><br>');
      > document.write( 'Ending folder should be <b>' + varAdd +
      > '</b><br><br>');
      >
      > /*Commands used to bring system to standard for file transfer*/
      >
      > document.write( 'cd\\<br>')
      > document.write( 'cd documents and settings\\chris topher
      > neu\\desktop<br >')
      > document.write( 'mkdir transfer<br>')
      > document.write( 'cd transfer<br>')
      >
      > /*copies files from smartmedia to transfer folder*/
      >
      > document.write( 'copy d:\\dcim\\100_f uji\\*.jpg<br>' )
      >
      > /*calculates and writes proper amount of folders in the transfer
      > folder via the "mkdir" command to properly transfer files*/
      >
      > for (count1=f2;coun t1<=varAdd;coun t1++)
      > if (count1 <=9)
      > document.write( 'mkdir ',var9999 + count1 +'<br>');
      > else if (count1 <=99)
      > document.write( 'mkdir ',var9 + count1 +'<br>');
      > else if (count1 <=999)
      > document.write( 'mkdir ',var99 + count1 +'<br>');
      > else if (count1 <=9999)
      > document.write( 'mkdir ',var999 + count1 +'<br>');
      > else
      > document.write( 'mkdir ' + count1 +'<br>');
      >
      >
      > /*moves pictures into proper folders. This is where the problem is.
      > I need to put the count that produced the folders after .jpg and have
      > it start fresh and continue till the move images count is done.
      > Perhaps this can be done with a function but i can not figure it out.
      > I can not figure out functions at all actually. :)*/
      >
      > for (count=1;count< =varImg;count++ )
      > if (count <=9)
      > document.write( 'move dscf',var9 + count +'.jpg <br>');
      > else if (count <=99)
      > document.write( 'move dscf',var99 + count +'.jpg <br>');
      > else if (count <=999)
      > document.write( 'move dscf',var999 + count +'.jpg <br>');
      > else
      > document.write( 'move dscf' + count +'.jpg <br>');
      >
      > </script>
      > </td>
      > </tr>
      > </table>
      > </body>
      > </html>[/color]


      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • McKirahan

        #4
        Re: Multiple loops. Please help. Desperate.

        "Christophe r N" <isa16w16w@yaho o.com> wrote in message
        news:4029b1dd$0 $198$75868355@n ews.frii.net...[color=blue]
        >
        >
        > Thanks for the response.
        >
        > if you do not mind readin a minute i will explain the background of the
        > script to better help understand the result.
        >
        > Here is the scenario:
        >
        > Where i work we have many roving photographers. each of these
        > photographers has a memory card that can hold x number of photos. When
        > they take a photo of someone they give them a numbered card. The
        > photographer copies 1 image to one folder and then 2nd image to second
        > folder and so forth. These folders have the same number as the
        > corresponding card the customer recieved.
        >
        > The customer then can go to a kiosk and enter card number onto the
        > screen. The corresponding folder is accessed and the photo is shown.
        > The problem with this is if the photographer messes up and puts a
        > picture in the wrong folder then the whole system is thrown off and we
        > have to try to find the problem and fix it. if they do it twice then we
        > are really up the creek.
        >
        > The script i wrote is my attempt to remove the human factor. The reason
        > it is javascript in html is because that is the only thing that i have
        > any remote experience in.
        >
        > You said it exactly.
        >
        > I want to first copy all JPG images from
        > d:\dcim\100_fuj i\
        > into the folder
        > c:\documents and settings\christ opherneu\deskto p\transfer\
        >
        > Then create user definde subfolders within
        > c:\documents and settings\christ opherneu\deskto p\transfer\
        >
        > then move lowest numbered image into lowest numbered subfolder within
        > c:\documents and settings\christ opherneu\deskto p\transfer\
        >
        > The only constant in this whole little mess is the image name.
        > dscf0001.jpg being the lowest and going up from there.
        >
        > once the javascript finishes the photographer will just copy the text
        > and paste it in the command prompt. The instructions should go from
        > there.
        >
        > here is the code with the changes you suggested. I kew about them but
        > forgot to do it. Thanks for reminding me! :) Thanks in advance for
        > any help you can provide.
        >
        > Chris[/color]


        How are the image names assigned? I have a Sony digital camera that burns
        images directly to a mini-CD and it sequences the pictures starting with
        "DSC00001.j pg". Thus, all pictures taken with this camera will have a
        unique image name even when I change CD's. In your case, i\It sounds like
        each photographer could take a picture with the same image number; for
        example, "dscf0001.j pg".

        Would you give an example of 2 pictures taken by 2 photographers.
        Here's an example for the first photographer; what about the second:

        Photographer #1
        cd\documents and settings\christ opherneu\deskto p\transfer
        mkdir 0001
        copy d:\dcim\100_fuj i\dscf0001.jpg 0001
        mkdir 0002
        copy d:\dcim\100_fuj i\dscf0002.jpg 0002

        Is "christopherneu " the name of a photographer?

        Also, do you want to use "copy" or "move"; that is, shopuld the pictures be
        deleted from the memory card?

        I'd probably suggest using an HTA (HTML for Applications) approach. The
        commands can be constructed and executed within it eliminating the need for
        cut-and-paste.


        Comment

        • Tank

          #5
          Re: Multiple loops. Please help. Desperate.

          "McKirahan" <News@McKirahan .com> wrote in message news:<mkkWb.314 0$yE5.18005@att bi_s54>...[color=blue]
          > "Christophe r N" <isa16w16w@yaho o.com> wrote in message
          > news:4029b1dd$0 $198$75868355@n ews.frii.net...[color=green]
          > >
          > >
          > > Thanks for the response.
          > >
          > > if you do not mind readin a minute i will explain the background of the
          > > script to better help understand the result.
          > >
          > > Here is the scenario:
          > >
          > > Where i work we have many roving photographers. each of these
          > > photographers has a memory card that can hold x number of photos. When
          > > they take a photo of someone they give them a numbered card. The
          > > photographer copies 1 image to one folder and then 2nd image to second
          > > folder and so forth. These folders have the same number as the
          > > corresponding card the customer recieved.
          > >
          > > The customer then can go to a kiosk and enter card number onto the
          > > screen. The corresponding folder is accessed and the photo is shown.
          > > The problem with this is if the photographer messes up and puts a
          > > picture in the wrong folder then the whole system is thrown off and we
          > > have to try to find the problem and fix it. if they do it twice then we
          > > are really up the creek.
          > >
          > > The script i wrote is my attempt to remove the human factor. The reason
          > > it is javascript in html is because that is the only thing that i have
          > > any remote experience in.
          > >
          > > You said it exactly.
          > >
          > > I want to first copy all JPG images from
          > > d:\dcim\100_fuj i\
          > > into the folder
          > > c:\documents and settings\christ opherneu\deskto p\transfer\
          > >
          > > Then create user definde subfolders within
          > > c:\documents and settings\christ opherneu\deskto p\transfer\
          > >
          > > then move lowest numbered image into lowest numbered subfolder within
          > > c:\documents and settings\christ opherneu\deskto p\transfer\
          > >
          > > The only constant in this whole little mess is the image name.
          > > dscf0001.jpg being the lowest and going up from there.
          > >
          > > once the javascript finishes the photographer will just copy the text
          > > and paste it in the command prompt. The instructions should go from
          > > there.
          > >
          > > here is the code with the changes you suggested. I kew about them but
          > > forgot to do it. Thanks for reminding me! :) Thanks in advance for
          > > any help you can provide.
          > >
          > > Chris[/color]
          >
          >
          > How are the image names assigned? I have a Sony digital camera that burns
          > images directly to a mini-CD and it sequences the pictures starting with
          > "DSC00001.j pg". Thus, all pictures taken with this camera will have a
          > unique image name even when I change CD's. In your case, i\It sounds like
          > each photographer could take a picture with the same image number; for
          > example, "dscf0001.j pg".[/color]

          That is correct. each photographer starts from dscf0001.jpg each
          time. this is because after uploading thier pictures they reformat
          the card in the camera. That restarts the camera count.[color=blue]
          >
          > Would you give an example of 2 pictures taken by 2 photographers.
          > Here's an example for the first photographer; what about the second:
          >
          > Photographer #1
          > cd\documents and settings\christ opherneu\deskto p\transfer
          > mkdir 0001
          > copy d:\dcim\100_fuj i\dscf0001.jpg 0001
          > mkdir 0002
          > copy d:\dcim\100_fuj i\dscf0002.jpg 0002
          >[/color]
          It would be almost exactly the same for the second photographer. the
          only change is the final folder number that each image is moved into.
          [color=blue]
          > Is "christopherneu " the name of a photographer?[/color]

          Thats me. I figure i will be guinea pig. You know... Lead from the
          fron not the rear.
          [color=blue]
          >
          > Also, do you want to use "copy" or "move"; that is, shopuld the pictures be
          > deleted from the memory card?[/color]

          Does not matter. Does not matter at all. The cards will get wiped
          when they are put back in the camera. So wether move, cut, or copy is
          moved doesnt really matter.[color=blue]
          >
          > I'd probably suggest using an HTA (HTML for Applications) approach. The
          > commands can be constructed and executed within it eliminating the need for
          > cut-and-paste.[/color]

          Once I get the thing working i am gonna try about a million different
          ways to do it. What programs do i use for hta? will just a text
          editor work?

          Thanks for putting up my ignorance on these matters. I have spent
          many many many hours trying to pull this off and still come up empty
          handed.

          Comment

          • McKirahan

            #6
            Re: Multiple loops. Please help. Desperate.


            "Tank" <isa16w16w@yaho o.com> wrote in message
            news:991bf7ca.0 402110534.106e4 7ac@posting.goo gle.com...
            [color=blue]
            > ... each photographer starts from dscf0001.jpg each time.[/color]
            [color=blue][color=green]
            > > Would you give an example of 2 pictures taken by 2 photographers.
            > > Here's an example for the first photographer; what about the second:
            > >
            > > Photographer #1
            > > cd\documents and settings\christ opherneu\deskto p\transfer
            > > mkdir 0001
            > > copy d:\dcim\100_fuj i\dscf0001.jpg 0001
            > > mkdir 0002
            > > copy d:\dcim\100_fuj i\dscf0002.jpg 0002
            > >[/color]
            > It would be almost exactly the same for the second photographer. the
            > only change is the final folder number that each image is moved into.[/color]

            This is what's confusing: if two photographers each take one picture with
            different cameras then the image names are the same -- according to your
            "spec", wouldn't they go in the same folder? If not what am I missing?
            Perhaps, I just need a more concise "spec" that discusses this situation.
            [color=blue][color=green]
            > > Is "christopherneu " the name of a photographer?[/color]
            >
            > Thats me. I figure i will be guinea pig. You know... Lead from the
            > fron not the rear.[/color]

            I was thinking that each photographer would create folders under his/her own
            name... but I guess not.
            [color=blue]
            > Once I get the thing working i am gonna try about a million different
            > ways to do it. What programs do i use for hta? will just a text
            > editor work?[/color]

            HTAs are basically HTML pages that allow you to do stuff like read and write
            files and execute commands such as "mkdir" and "copy". Any text editor can
            be used. Here is a simple HTA that makes a new directory and copies a file
            to it; watch for word-wrap.


            <html>
            <HTA:APPLICATIO N ID="MakeCopy"
            APPLICATIONNAME ="MakeCopyHT A">
            <head>
            <title>MakeCopy .hta</title>
            <script type="text/vbscript">
            Option Explicit
            Const cHTA = "MakeCopy.h ta"

            Sub MakeCopy()
            Dim strDIR
            strDIR = "C:\Temp\MakeCo py." & DatePart("s",Ti me)
            Dim strFIL
            strFIL = "C:\config. sys"
            Dim objFSO
            Set objFSO = CreateObject("S cripting.FileSy stemObject")
            If objFSO.FolderEx ists(strDIR) Then
            objFSO.DeleteFo lder(strDIR)
            End If
            objFSO.CreateFo lder(strDIR)
            objFSO.CopyFile strFIL, strDIR & Mid(strFIL,InSt r(strFIL,"\"))
            Set objFSO = Nothing
            MsgBox strDIR & " created!",vbInf ormation,cHTA
            End Sub
            </script>
            </head>
            <body>
            <form>
            <input type="button" value="MakeCopy " onclick="MakeCo py()">
            </form>
            </body>
            </html>



            Comment

            Working...