Naguib Ihab
Naguib Ihab

Reputation: 4506

Loop on directories using a batch file and paste folders

Consider that I have this structure:

E:
-- /Company/
----/- Migrations -/
------/- All environments/
--------/A/
--------/B/
--------/C/
--------/D/

And I want to copy a folder for example (E:\Company\folder) into all the folders inside "- All environments" so into folders A,B,C and D. I however am stuck at looping on the folders and haven't got the the point where I can copy the folder yet.

This is my current code

FOR /D %i  in ("E:\Company\- Migrations -\- All environments\*") DO ECHO %i

I'm expecting to echo the names of the folders, however nothing is coming out, what am i doing wrong?

Upvotes: 1

Views: 38

Answers (1)

Naguib Ihab
Naguib Ihab

Reputation: 4506

As usual after searching for 2 hours without finding an answer, I have found it right after putting this question.

The correct syntax is

FOR /D %%i  in ("E:\Company\- Migrations -\- All environments\*") DO ECHO %%i

Upvotes: 1

Related Questions