|
Answer» Hi All,
I thought I would start a new post. I'm new to batch but learning quickly.
The below batch only partially WORKS for me. When running the batch if you hit enter without adding a client name it will add the next folder in sequence, which is fine. But when you enter a client name which is what I want to do every time, the first outcome is correct, e.g. the next available folder number with the client name following, 15-P0015 Brown for example. But, if you run it again you get 15-P0015 Green for example, instead of 15-P0016 Green.
Can anyone help me, I just can't FIGURE it out!! Thanks a lot in advance for any help provided
echo off setlocal enableDelayedExpansion cd /d C:\Users\jbrown\Desktop\Test set I=2 :NextI if /I %I% LEQ 999 set II=0%I% if /I %I% LEQ 99 set II=00%I% if /I %I% LEQ 9 set II=000%I% if not exist "15-P!II!" ( set /p "client_name=OPTIONAL Enter a client name and press : "
xcopy /s /e /i "15-P0000-Template" "15-P!II!!client_name!" goto :eof ) set /a I+=1 if /i %I% LSS 999 goto NextI )
[attachment deleted by admin to conserve space]echo off setlocal enableDelayedExpansion cd /d D:\Test set I=2 :NextI if /I %I% LEQ 999 set II=0%I% if /I %I% LEQ 99 set II=00%I% if /I %I% LEQ 9 set II=000%I% if not exist "15-P!II!" ( set /p "client_name=OPTIONAL Enter a client name and press <ENTER>: "
xcopy /s /e /i "15-P0000-Template" "15-P!II!!client_name!" goto :eof ) set /a I+=1 if /i %I% LSS 999 goto NextI ) <----------- Why is this here?
Not sure?? I asked someone way BACK for some help and he said that would work??Is it the same answer for this?
echo off setlocal enableDelayedExpansion cd /d C:\Users\jbrown\Desktop\Test set I=2 :NextI if /I %I% LEQ 999 set II=0%I% if /I %I% LEQ 99 set II=00%I% if /I %I% LEQ 9 set II=000%I% if not exist "15-P!II!" ( set /p "client_name=OPTIONAL Enter a client name and press <ENTER>: "
xcopy /s /e /i "15-P0000-Template" "15-P!II!!client_name!" goto :eof <----------- Why is this here? ) set /a I+=1 if /i %I% LSS 999 goto NextI ) Yes. As I said I'm new to batch but really trying to understand, but I just can't figure out how to make it work the way I want.
Thanks I think you might now know which lines to remove. Yes, but even with them removed the same problem is still there?? The batch still only works correctly for the first time EG: 15-P0002 Test but when run again using testing as the next name the out put is 15-P0002 testing instead of 15-P0003 testing.
echo off setlocal enableDelayedExpansion cd /d C:\Users\jbrown\Desktop\Test set I=2 :NextI if /I %I% LEQ 999 set II=0%I% if /I %I% LEQ 99 set II=00%I% if /I %I% LEQ 9 set II=000%I% if not exist "15-P!II!" ( set /p "client_name=OPTIONAL Enter a client name and press : "
xcopy /s /e /i "15-P0000-Template" "15-P!II!!client_name!" ) set /a I+=1 if /i %I% LSS 999 goto NextIOPTIONAL Enter a client name and press <ENTER>: test xcopy /s /e /i "15-P0000-Template" "15-P0002test" OPTIONAL Enter a client name and press <ENTER>: testing xcopy /s /e /i "15-P0000-Template" "15-P0003testing" Sorry, I don't follow what you are saying?? Capture.jpeg shows the result I get when I run the program 3 times adding 3 different names. Capture 2.jpeg shows the result that I am looking for.
[attachment deleted by admin to conserve space]Read what I posted. Is it what you want to happen? Sorry, yes exactly!I deleted the 2 lines which I have previously indicated. Yes that works until you close it and then reopen the batch. It then STARTS from the beginning number instead of the next in the sequence? Of course it will! How can it know about previous runs? You have hard coded the start number (set I=2).
OF COURSE!!!!! Now I get it. Thanks a million for all of your help
|