DOS For Do Goto Replaces Call?

Cool title huh. Anyway, I've been using two DOS batch files and would like to consolidate them into one batch file. Unsure how to do the 'Call'.

( Batch File #1 )
For %%i In (\bin\*.dll) Do (Call BatchFile2.bat "%%~i")

( Batch File #2 )
set "ESP=C:\Program Files\eSoft\Protector"
set "SAFE=%1"
"%ESP%"\Protector.exe
-source %1
-target %SAFE%

( Possible One Batch File Solution Not Working )
For %%i In (\bin\*.dll) Do (Goto NEXT "%%~i")
:NEXT
set "ESP=C:\Program Files\eSoft\Protector"
set "SAFE=%1"
"%ESP%"\Protector.exe
-source %1
-target %SAFE%
WorknHardrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewCommented:
This should work, just put the logic you need inside the FOR loop as shown.

@echo off
set "ESP=C:\Program Files\eSoft\Protector"
For %%i In (\bin\*.dll) Do (
  "%ESP%"\Protector.exe -source %%~i -target %%~i
)

Open in new window

~bp
0
WorknHardrAuthor Commented:
yea, more logical. I need the target file path different from the source. I've been using this substitution syntax, not working now:

set "ESP=C:\Program Files\eSoft\Protector"
set "SAFE=%1"
Set "SAFE=%SAFE:Published=Release%"

"%ESP%"\Protector.exe
-source %1
-target %SAFE%
0
Bill PrewCommented:
To change variable values inside a FOR loop and then reference them you you have to use delayed expansion as follows:

@echo off
setlocal EnableDelayedExpansion

set "ESP=C:\Program Files\eSoft\Protector"

for %%i in (\bin\*.dll) do (
  set "SAFE=%1"
  set "SAFE=!SAFE:Published=Release!"
  "%ESP%"\Protector.exe -source %%~i -target !Safe!
)

Open in new window

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WorknHardrAuthor Commented:
Thx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.