Multiple loops. Please help. Desperate.

T

Tank

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='javascript'>

folder = window.prompt('starting folder','default');
picnumber = window.prompt('pictures taken?','default');
f2 = parseFloat(folder);
p2 = parseFloat(picnumber);


/*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\\christopher
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_fuji\\*.jpg<br>')

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

for (count1=f2;count1<=varAdd;count1++)
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>
 
M

McKirahan

Tank said:
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='javascript'>

folder = window.prompt('starting folder','default');
picnumber = window.prompt('pictures taken?','default');
f2 = parseFloat(folder);
p2 = parseFloat(picnumber);


/*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\\christopher
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_fuji\\*.jpg<br>')

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

for (count1=f2;count1<=varAdd;count1++)
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>

Running your code generates a page with:

Starting folder is 2
Ending folder should be 4

cd..
cd documents and settings\christopherneu\desktop
mkdir transfer
cd transfer
copy d:\dcim\100_fuji\*.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_fuji\
into a user specified range of subfolders under
c:\documents and settings\christopherneu\desktop\transfer\
etc.
 
C

Christopher N

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_fuji\
into the folder
c:\documents and settings\christopherneu\desktop\transfer\

Then create user definde subfolders within
c:\documents and settings\christopherneu\desktop\transfer\

then move lowest numbered image into lowest numbered subfolder within
c:\documents and settings\christopherneu\desktop\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
 
M

McKirahan

Christopher N said:
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_fuji\
into the folder
c:\documents and settings\christopherneu\desktop\transfer\

Then create user definde subfolders within
c:\documents and settings\christopherneu\desktop\transfer\

then move lowest numbered image into lowest numbered subfolder within
c:\documents and settings\christopherneu\desktop\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


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.jpg". 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.jpg".

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\christopherneu\desktop\transfer
mkdir 0001
copy d:\dcim\100_fuji\dscf0001.jpg 0001
mkdir 0002
copy d:\dcim\100_fuji\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.
 
T

Tank

McKirahan said:
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.jpg". 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.jpg".

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.
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\christopherneu\desktop\transfer
mkdir 0001
copy d:\dcim\100_fuji\dscf0001.jpg 0001
mkdir 0002
copy d:\dcim\100_fuji\dscf0002.jpg 0002
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.
Is "christopherneu" the name of a photographer?

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

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.
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.

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.
 
M

McKirahan

... each photographer starts from dscf0001.jpg each time.
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.

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.
Thats me. I figure i will be guinea pig. You know... Lead from the
fron not the rear.

I was thinking that each photographer would create folders under his/her own
name... but I guess not.
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?

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:APPLICATION ID="MakeCopy"
APPLICATIONNAME="MakeCopyHTA">
<head>
<title>MakeCopy.hta</title>
<script type="text/vbscript">
Option Explicit
Const cHTA = "MakeCopy.hta"

Sub MakeCopy()
Dim strDIR
strDIR = "C:\Temp\MakeCopy." & DatePart("s",Time)
Dim strFIL
strFIL = "C:\config.sys"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDIR) Then
objFSO.DeleteFolder(strDIR)
End If
objFSO.CreateFolder(strDIR)
objFSO.CopyFile strFIL, strDIR & Mid(strFIL,InStr(strFIL,"\"))
Set objFSO = Nothing
MsgBox strDIR & " created!",vbInformation,cHTA
End Sub
</script>
</head>
<body>
<form>
<input type="button" value="MakeCopy" onclick="MakeCopy()">
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top