Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

run a process over a variable number of files

2 views
Skip to first unread message

happytoday

unread,
May 16, 2010, 4:57:39 AM5/16/10
to
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%

)

billious

unread,
May 16, 2010, 5:11:32 AM5/16/10
to

"happytoday" <ehabaz...@gmail.com> wrote in message
news:b6d27688-7ce6-49eb...@k31g2000vbu.googlegroups.com...

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)

ten.n...@virgin.net

unread,
May 16, 2010, 9:49:16 AM5/16/10
to

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!

0 new messages