Go Back   PackageDeploy Application Packaging Forums > Package Development > Application Deployment > Microsoft SMS 2003

Reply
 
LinkBack Thread Tools Display Modes
Old 05-16-2010, 10:01 AM   #1 (permalink)
happytoday
Guest
 
Posts: n/a
Default run a process over a variable number of files

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%

)

  Reply With Quote
Old 05-16-2010, 11:01 AM   #2 (permalink)
billious
Guest
 
Posts: n/a
Default Re: run a process over a variable number of files


"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)



  Reply With Quote
Old 05-16-2010, 03:01 PM   #3 (permalink)
ten.nigriv@virgin.net
Guest
 
Posts: n/a
Default Re: run a process over a variable number of files

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!
  Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:16 AM.


vBulletin, Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
2007 - 2012 PackageDeploy.com