Skip to content

Instantly share code, notes, and snippets.

@izimbra
Last active September 28, 2016 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save izimbra/f7100034488e173cab38 to your computer and use it in GitHub Desktop.
Save izimbra/f7100034488e173cab38 to your computer and use it in GitHub Desktop.
Set variable values inside for-loop.
@echo off
:: enable delayed expansion to set variable values inside for-loop
:: usual %VAR% syntax won't work, use !VAR! instead
setlocal EnableDelayedExpansion
for %%A in (%*) do (
set _PARAM=%%A
set _PREFIX=!_PARAM:~0,3!
if /i !_PREFIX!==SearchString (
set LIST_VAR=!LIST_VAR! !_PARAM!
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment