TransWikia.com

DOS Copy command to multiple folders

Super User Asked by user3711329 on January 8, 2021

I want to copy a file from one folder to another folder which has many sub-folders. Using MS-DOS command, how can I copy this file to all sub-folders. Can any one please help me on this?

Eg. I have a file called Test.txt. I want to copy this file to another folder “Data”, which has many subfolders ‘Data-1’, ‘Data-2’, ‘Data-3’ etc. Using DOS command I want to copy this text file to all these sub-floders in a single stretch.

3 Answers

Assuming by 'MS-DOS' you mean Windows' Command Prompt, use robocopy with the /mir switch:

robocopy /mir <source> <destination>

for all the options this tool can offer type robocopy /?

Answered by Azevedo on January 8, 2021

Use the advanced for command...

for /D %%f in ("%1*") do copy "%2" "%%f"

  • The first argument is the destination directory
  • The second argument is the file to be copied

Answered by Jared Newnam on January 8, 2021

@echo off
for /d /r "d:folder 2" %%a in (*) do copy "d:folder 1test.txt" "%%a"

Answered by foxidrive on January 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP