在嵌套for循环中未正确设置变量

时间:2018-01-30 17:41:36

标签: batch-file variables nested-loops

我搜索过关于此主题的无数帖子并多次更改了代码,但使用以下(更新)代码的最终结果始终是myfiledateNow变量为空。有人可以帮忙吗?谢谢!

代码:(见下面的结果)

@SETLOCAL ENABLEDELAYEDEXPANSION
set themes=CDTNEW,CFTNEW
for %%z in (%themes%) do (
set "Now=C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora\Files_Helper\%%~z_Now.csv"
for %%a in (!Now!) do (
  set myfiledateNow=%%~ta
)
)

结果:

C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora>set themes=CDTNEW,C
FTNEW

C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora>for %z in ("CDTNEW"
"CFTNEW") do (
set "Now=C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora\Files_Help
er\%~z_Now.csv"
for %a in (!Now!) do (set myfiledateNow=%~ta )
)

C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora>(
set "Now=C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora\Files_Help
er\CDTNEW_Now.csv"
for %a in (!Now!) do (set myfiledateNow=%~ta )
)

C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora>(set myfiledateNow=
)

C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora>(
set "Now=C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora\Files_Help
er\CFTNEW_Now.csv"
for %a in (!Now!) do (set myfiledateNow=%~ta )
)

C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora>(set myfiledateNow=
)

C:\Users\psnider\Documents\Stuff\MISCELLANEOUS\ArchiveAurora>Pause
Press any key to continue . . .

1 个答案:

答案 0 :(得分:1)

以下是我根据您的不完整问题提供的最佳信息。

stream create --name test --definition "http | filter --expression='!(payload.firstName==''Joe Robert'' and (payload.lastname==''Smith'' or payload.prod==''Williams''))' |log"