How to store the result of a command expression in a variable using bat scripts?

前端 未结 5 1981
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 23:10

I have the command below to count all directories that that follow the pattern 20?????? :

\'dir /b \"20??????\" | find /c \"2\"\'
5条回答
  •  死守一世寂寞
    2020-12-02 23:54

    This is my code:

    @echo off
    set com=echo HI
    ::Start Of Code You Need
    echo|%com%>>"%temp%\tmp.txt"
    for /f "tokens=* delims=" %%x in (%temp%\tmp.txt) do (
    set output=%%x
    )
    del /q %temp%\tmp.txt
    ::End Of Code You Need
    echo This Is The Output:
    echo %output%
    pause>NUL
    

    It takes the input from com and outputs from output

提交回复
热议问题