Dilip K
Dilip K

Reputation: 81

How do I copy files from parent folder to sub folders using batch file?

Can anyone help me to solve this problem?

Eg :

  1. FolderA contains 123.txt.

  2. FolderB contains FolderB1, FolderB2, etc.

I want to copy the files from FolderA to FolderB1, FolderB2, etc. using batch file.

Upvotes: 0

Views: 1837

Answers (2)

mojo
mojo

Reputation: 4132

Use a for loop to iterate over the target direcories.

FOR /D %%d IN (\Path\to\FolderB\*) DO copy \Path\to\FolderA\123.txt "%%~d"

Upvotes: 1

Endoro
Endoro

Reputation: 37569

pushd "\Path\to\folderB"
for /r /d %%a in (*) do cd "%%~fa" & copy "\Path\to\FolderA\123.txt"
popd

Upvotes: 0

Related Questions