Assign the output of a command to a variable in CMD

FOR /F "tokens=*" %%A IN ('dir "."') DO (
    SET var=%%A
)
ECHO %var%