Babalu Pandey
Babalu Pandey

Reputation: 58

Copy code in batch file to subfolders

I have just heard that we can copy the file to all its subfolders using a batch file.

I have a file named code.php and many folders in project folder.

Now instead of copy-paste code.php in all its(project) sub folders one by one. Is there any code in the batch file that will do the same, by opening batch file once.

Upvotes: 0

Views: 69

Answers (1)

Compo
Compo

Reputation: 38654

Hopefully this should do what you want.

At the Command Prompt:

For /D /R "C:\project" %A In (*) Do @Copy "C:\code.php" "%A">Nul

or in a batch file:

@For /D /R "C:\project" %%A In (*) Do @Copy "C:\code.php" "%%A">Nul

Change the parent root folder path C:\project and source file name and path C:\code.php accordingly.

Upvotes: 1

Related Questions