私が知る限り、そのvarには文字列が1つしかないため、現在は1を数えています。後で分割しますが、トークン数はすでに1に設定されています....
最初の文字列 (delims=,) を分割し、2 番目の部分で各結果を処理する必要があります。
編集済み:
これを試して...
@echo off
set collection=collection1
set environment=oracleDev
set processChain1="-help" "-startimport %environment% %collection%"
Set count=0
For %%j in (%processChain1%) Do Set /A count+=1
echo.Total count: %count%
pause
ご覧のとおり、var processChain1構造を変更して、値をスペース (デフォルトの区切り文字) で区切り、すべての var を引用符で囲みます... 少なくとも機能し、合計カウントが得られます。
もちろん、このように使用できる場合に限ります。
それが役に立てば幸い。乾杯。
そうでない場合は、こちらをご覧ください。おそらく助けになるでしょう:バッチファイル内の個別のトークン
幸運を
EDITED 2 (新しい情報に合わせて)
バッチ ファイル: Metalhead89.bat
@echo off
:: define the vars
set collection=collection1
set environment=oracleDev
:: concatenate the vars with ++
set processChain1=-help -startimport++%environment%++%collection%
:: Get the total count plus, run each token found
Set count=0
For %%j in (%processChain1%) do (
Set /A count+=1
set line=%%j
call :processToken
)
:: This will be printed out, at the end of the loop
echo Total token count: %count%
goto :eof
:processToken
for /f %%f in ("%line%") do (
:: set the command var with your exe file for each token found
set command=Running command: java -jar app.jar %%f
call :runTheCommand
)
goto :eof
:runTheCommand
:: now we replace the doble ++ in the var string with space, to treat them as options
set str=%command%
set str=%str:++= %
:: finally we do a echo of the command with the option included
echo %str%
goto :eof
ここで、コマンドラインからそのファイルを呼び出すと、次のようになります。
Z:\>call Metalhead89.bat
Running command: java -jar app.jar -help
Running command: java -jar app.jar -startimport oracleDev collection1
Total token count: 2
幸運の相棒;-)