Search and copy multiple folder by file list

I have a list of names of folders in a txt file and I want to do a search in a folder that should work this way: if the name of the folder (which is written in the txt file) is in the path, then copy that folder and all its content (files and subdirectories) in the folder C:\okcopied

Example general folder content:

  • папка 1
  • папка 2
  • folder 3
  • folder 4
  • folder 5

Sample file.txt:

  • папка 1
  • folder 3

End result log folder:

  • folder 1, subdirectories and files was copied
  • folder 3, subdirectories and files was copied

Как я могу сделать? Я пробовал с:for /D %t in (C:\test\file.txt) do copy %t c:\okcopied но это не работает This command copies the file "file.txt" to the C:\okcopied папка.

1 ответ

for /f "usebackq delims=" %%a in ("c:\test\file.txt"
) do if exist ".\%%a\" robocopy ".\%%a" "c:\okcopied\%%a" * /e
Другие вопросы по тегам