Reputation: 993
How to extract a set of commands from a bat
file respecting certain pattern and run them in bach?
example : file.txt
export TOOLCHAIN="multi"
# Version of toolchain (optional)
# Location of toolchain (optional for WINDOWS)
export TOOLPATH="D:/Tools/compiler/GHS/GHS_COMPILER/PPC"
in this example, I'm looking for a command which could
export
output:
set TOOLCHAIN="multi"
set TOOLPATH="D:/Tools/compiler/GHS/GHS_COMPILER/PPC"
Upvotes: 0
Views: 79
Reputation:
Maybe this?:
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('type file.txt ^|findstr /B "export"') do (
set "output=%%i"
set myCMD=!output:export=set!
echo !myCMD!
)
Simply loop through type command of file.txt
then findstr
the word export in the beginning of the line, and replace with set.
This will simply echo
the full command, you can remove echo
when happy with the results to actually run set command.
Upvotes: 3