Search code examples
windowscopyxcopy

Windows copy a file in the same subfolder but in different folders


Okey, so here is my problem.

I have a folder with many user folders. I every use folder there is the same folder subfolder1 and i want to copy a file to subfolder1 so it looks something like this:

> C:\Folder\
>           user1\subfolder1
>           user2\subfolder1
>           user3\subfolder1
>           ...

and I want to copy file for every user in subfolder1. Something like this:

copy C:\Folder\File C:\Folder*\subfolder1\

In linux that would probably do the trick but in Windows I can't figure it out, so please if somebody can help I will be very grateful!

The operating system is Windows XP, but if really necessary I can do it on Windows 10.

Thanks in advance.


Solution

  • From the command line, execute this:

    for /D %f in (*) do copy my.file %f\subfolder1\my.file
    

    If you put it in a batch file, replace %f with %%f

    This is a for loop over directories, (/D) without recursion.