Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I need to run a particular se of commands repetatively for some number of times provided by userin for loop.
I am doing it this way
user input the no of arguments and arguments
i.e 3 d:\\input.txt d:\\dir1 d:\\dir2
my batch file
set k=%%1
for %%i(%%(k-2)
do
cd %%(k-1) //comment: i want to go to dir1
java tsafe.main.Main //command to be run
copy %%i d://dir3//test1.txt
serve.py //command to be run
done
but nothing is working
i was doing this shell script earlier with cygwin .
Any help greatly appreciated
Thanks

hello, sorry, im pretty handy with batch files, but to tell ya the truth, i dont pay attention to use all thet %1 stuff, except when i make a menu like '%choice%' but i know how to make a loop, im not sure if its what your looking for but here is a loob to tell the time and date...
echo off
title loop
cls
:up
echo %date% %time
cls
goto upand that would update the time and date every split second...is this any help ?

Hi Shrads,
If that's your real code, you have a couple obvious problems.
1. The path separator in DOS & windows is the SINGLE backslash.
So these won't help:
d:\\dir1
d://dir3//test1.txt2. I guess you mean to use this as a comment
//command to be run
as in C or C++
It won't work in batch. In batch, a comment goes on a line by itself, preceeded by
::
or
rem [and at least one space]
examples:
::this is a comment
rem this is a comment
remthis is a mess
dir //this is also a messAfter you wring out those problems, post back.
HTH
M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |