|
|
#1 (permalink) |
|
Guest
Posts: n/a
|
I can not manage adding a numeric variable counter at the end of the
string batfilename as this will yield a file name with variable number at the end . @echo off set pathlogs=G:\programs\batch\al-watani set filename2=test.txt set count=0 setlocal enabledelayedexpansion for /L %%1 IN (1,1,10) do ( set /a count=!count! + 1 if !count! LEQ 9 (set branchnumber=0!count!) if !count! GEQ 10 (set branchnumber=!count!) set batfilename=%pathlogs%\%filename2%_!batchnumber! echo !count! run_process on %batfilename% ) |
|
|
|
#2 (permalink) |
|
Guest
Posts: n/a
|
"happytoday" <ehabaziz2001@gmail.com> wrote in message news:b6d27688-7ce6-49eb-a44c-fd964b28d043@k31g2000vbu.googlegroups.com... >I can not manage adding a numeric variable counter at the end of the > string batfilename as this will yield a file name with variable number > at the end . > > @echo off > set pathlogs=G:\programs\batch\al-watani > set filename2=test.txt > set count=0 > setlocal enabledelayedexpansion > for /L %%1 IN (1,1,10) do ( > set /a count=!count! + 1 > if !count! LEQ 9 (set branchnumber=0!count!) > if !count! GEQ 10 (set branchnumber=!count!) > set batfilename=%pathlogs%\%filename2%_!batchnumber! > echo !count! > run_process on %batfilename% > > ) > No idea of what you are trying to do, but perhaps changing 'batchnumber' to 'branchnumber' in the tenth line may help. Oh - and run_process on %batfilename% should be run_process on !batfilename! otherwise the value of BATFILENAME at the time the FOR /L was parsed will be used (and likely that's empty) |
|
|
|
#3 (permalink) |
|
Guest
Posts: n/a
|
On Sun, 16 May 2010 01:57:39 -0700 (PDT), happytoday wrote:
> I can not manage adding a numeric variable counter at the end of the > string batfilename as this will yield a file name with variable number > at the end . > > @echo off > set pathlogs=G:\programs\batch\al-watani > set filename2=test.txt > set count=0 > setlocal enabledelayedexpansion > for /L %%1 IN (1,1,10) do ( > set /a count=!count! + 1 > if !count! LEQ 9 (set branchnumber=0!count!) > if !count! GEQ 10 (set branchnumber=!count!) > set batfilename=%pathlogs%\%filename2%_!batchnumber! > echo !count! > run_process on %batfilename% > > ) Would something like this not suit your purpose better. :: ----- START ----- @ECHO Off SETLOCAL (SET pathlogs=G:\programs\batch\al-watani) (SET filename2=test) (SET fname2ext=.txt) (SET count=0) (SET limit=12) CALL :sub GOTO :EOF :sub (SET/A count+=1) IF %count% LSS 10 (SET branchnumber=0%count%) ELSE (set branchnumber=%count%) (SET batfilename=%pathlogs%\%filename2%_%branchnumber%% fname2ext%) ECHO=run_process on %batfilename% IF %count% LSS %limit% GOTO sub :: ------ END ------ Just set limit to your chosen limit figure! |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|