-1

I want to store this command in a variable called code1

    dir /a:d /b

so the output would be: Folder1 Folder2 Folder3 etc... Any ideas how to do it? I've checked other questions and when it just sais echo is off.

Jumperz Ko
  • 371
  • 1
  • 3
  • 14

1 Answers1

3

Simply store the command in the variable like you say. To execute, simply expand the value:

@echo off
setlocal

:: Define a simple "macro"
set "code1=dir /a:d /b"

:: Execute the "macro"
%code1%
dbenham
  • 127,446
  • 28
  • 251
  • 390