如何批量迭代数组key = value item [英] How to iterate over array in batch for key=value item

查看:163
本文介绍了如何批量迭代数组key = value item的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组定义为 LIST =(a b c d e) a,b,c,d,e 被设置为系统变量,例如。 a = AAA,b = BBB

在批处理脚本中,我想做一个for循环看起来像:

  for %% i%in%LIST%do echo %% i = %%% i%(不幸的是,这是行不通的)

我想达到的是 %% i(a)= %%% i%(%a%),它将被解析为系统变量,而不是显示%a%,它将被解析为 a = AAA



你有什么想法如何做一个批处理脚本?



谢谢!

解决方案

< code%for %% i in%LIST%do CALL echo %% i = %%%% i %%

可以解决你的问题。


I have an array defined as LIST=(a b c d e). The a, b, c, d, e are set as system variables, eg. a=AAA, b=BBB, etc.

In a batch script, I would like to do a for loop looking like:

for %%i in %LIST% do echo %%i=%%%i% (unfortunately, this doesn't work)

What I want to achieve is that %%i (a) = %%%i% (%a%), which will be resolved as system variable, thus instead of showing %a%, it'll be resolved as a=AAA.

Do you have any idea how to do it in a batch script?

Thanks!

解决方案

for %%i in %LIST% do CALL echo %%i=%%%%i%%

should solve your problem.

这篇关于如何批量迭代数组key = value item的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆