D
D
Dimon2020-03-04 21:24:49
Command line
Dimon, 2020-03-04 21:24:49

Need help writing a batch file using the set command?

In the Doki folder, for example, there are folders: 1,2,3 they contain different files, the exact names are unknown, so I decided to make such a command in a bat file that will display all the folders that are in the Doki folder with the dir command, creating set parameters with folder names
for / f "tokens=*" %%1 in ('dir /bz:\Doki') DO set G1=%%1
get
set G1="1"
set G1="2"
set G1="3"
how to make it do each folder separately set parameter
set G1="1"
set G2="2"
set G3="3"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2020-03-05
@Dimon256

Keep a counter of sets and add its value to the variable name. Schematically like this:

setlocal enabledelayedexpansion
set "count=0"
for /f "tokens=*" %%1 in ('dir /b z:\Doki') DO (
  set /a "count=!count!+1"
  set "G!count!=%%1
)

For reference see:
set /?
for /?
setlocal /?

S
sergey, 2020-03-05
kuzmin @sergueik

https://codengineering.ru/q/use-setlocal-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question