A
A
Artyom2021-12-21 01:45:54
cmd/bat
Artyom, 2021-12-21 01:45:54

How to copy folders from a directory using a mask?

I have a directory with subfolders in which there are folders called LOG and BACKUP in large numbers. How can I run a script from the directory that will find all LOG and BACKUP in subfolders and save them to a separate directory without merging (Like LOG1 , LOG2 ... and etc)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2021-12-21
@res2001

Search for folders by mask using dir: dir /b /ad c:\temp\log*
Put this dir in for /f:

for /f "tokens=* delims=" %%a in ('dir ...') do (
   echo %%a
)

In a cycle, we copy the selected folders.
To increment the folder counter, use For reference:set /a "logidx=logidx+1"
for /?
dir /?
set /?
if /?
copy /?
move /?
md /?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question