0

So i want to call all files in a directory with a variable in it and later echo the variable. The only problem i'm having is it won't echo out the variable. It just says ECHO OFF.

Here's my current code.

// THIS IS MY FOR LOOP.
@echo off

:Message
for %%i in (Soemthing\*.bat) do (
    call %%i
    echo %Message%
)

pause
exit

// THIS IS THE FILE I WANT IT TO CALL.
@echo off

set %Message%=Some message here.

1 Answers1

1
> type a.bat
@echo off
setlocal enabledelayedexpansion
:Message
for %%i in (b.bat) do (
    call %%i
    echo !Message!
)
pause

> type b.bat
set "Message=Some message here."

> a.bat

Some message here.
Drücken Sie eine beliebige Taste . . .

>
Stephan
  • 53,940
  • 10
  • 58
  • 91
  • I don't want it to call b.bat, i want instead (*.bat) so it calls every file. – Someone Something Jun 07 '16 at 14:32
  • this is called an example. To show you how it works. Of course you can replace `b.bat` with `Soemthing\*.bat` and it would call every single bat file in that folder. – Stephan Jun 07 '16 at 14:49