How to copy a file to many directories using prompt?

user4227915

I need to copy a file and paste it in many directories, can I do this with a single command in windows prompt? I tried this code, but it didn't work:

> copy C:\main\folder-1\docs\file.txt C:\main\*\docs    

The names are illustratives, but the idea is: inside the "main" folder I have 50 folders ("folder-1", "folder-2", ..., "folder-50")... and inside each "folder-N", I have other folder named "docs". Every time that I create a file into any "folder-N\docs" I need to paste it into all "folder-N\docs".

Is it possible? or I really need to paste the file, folder by folder?

selbie

Straight up from the command line:

for /D %x in (c:\main\*.*) DO COPY c:\main\folder-1\docs\file.txt %x\docs\file.txt

From a BAT file or CMD file (not from the command line), you need to escape the % variable again

for /D %%x in (c:\main\*.*) DO COPY c:\main\folder-1\docs\file.txt %%x\docs\file.txt

Of course, if the subdirectory "docs" directory doesn't exist in each subfolder of "main", the iteration will print an error. That's why in my example above I explicitly specify copying to %x\docs\file.txt. If I had just said `%x\docs" as the target of the copy, it might create a file called "docs" that contains the contents of the file.txt source.

More information on for loops here and here:

Or just type "help for" at the command prompt.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to browse unc directories using command prompt

From Dev

How can I use PowerShell to copy the same file to many directories with the same name?

From Dev

How to Copy Only the Directories with a specific File in that directory

From Dev

How to copy same file from different directories to different directories

From Dev

How to rename file during copy in command prompt

From Dev

How to copy directories into a directory using install in bash?

From Dev

How to copy directories into symbolic links using rsync?

From Dev

In Windows command prompt, copy one file (or multiple files) to multiple directories that have a user specified name

From Dev

Copy only directories from a command prompt

From Dev

Using xargs to copy directories

From Dev

how can I batch copy a file into multiple sub-directories?

From Dev

How to copy a file to a directory in DOS, and create directories if necessary?

From Dev

How do I create a copy of a file in multiple directories?

From Dev

How can I copy a file and create the target directories at the same time?

From Dev

How to delete a sub directory out of many directories using shell script

From Dev

How do I use the windows command prompt to copy a file

From Dev

Copy a file to several directories with gulp

From Dev

Ant only copy the file not directories

From Dev

How to do recursive copy of files and directories using ant task

From Dev

How do I subset and copy directories using a csv?

From Dev

How to get a prompt for information using a batch file?

From Dev

Copy a file to many folders

From Dev

How many directories can be nested?

From Dev

How to copy directories with preserving hardlinks?

From Dev

How to copy directories via ssh

From Dev

Copy files with certain extension from many nested sub-directories to a single directory and append to each copied file the name of the directory

From Dev

Windows script to delete and copy file to multiple directories

From Dev

Copy Single file to multiple directories [overwrite if there]

From Dev

Batch copy a specific file to all directories and subdirectories

Related Related

  1. 1

    How to browse unc directories using command prompt

  2. 2

    How can I use PowerShell to copy the same file to many directories with the same name?

  3. 3

    How to Copy Only the Directories with a specific File in that directory

  4. 4

    How to copy same file from different directories to different directories

  5. 5

    How to rename file during copy in command prompt

  6. 6

    How to copy directories into a directory using install in bash?

  7. 7

    How to copy directories into symbolic links using rsync?

  8. 8

    In Windows command prompt, copy one file (or multiple files) to multiple directories that have a user specified name

  9. 9

    Copy only directories from a command prompt

  10. 10

    Using xargs to copy directories

  11. 11

    how can I batch copy a file into multiple sub-directories?

  12. 12

    How to copy a file to a directory in DOS, and create directories if necessary?

  13. 13

    How do I create a copy of a file in multiple directories?

  14. 14

    How can I copy a file and create the target directories at the same time?

  15. 15

    How to delete a sub directory out of many directories using shell script

  16. 16

    How do I use the windows command prompt to copy a file

  17. 17

    Copy a file to several directories with gulp

  18. 18

    Ant only copy the file not directories

  19. 19

    How to do recursive copy of files and directories using ant task

  20. 20

    How do I subset and copy directories using a csv?

  21. 21

    How to get a prompt for information using a batch file?

  22. 22

    Copy a file to many folders

  23. 23

    How many directories can be nested?

  24. 24

    How to copy directories with preserving hardlinks?

  25. 25

    How to copy directories via ssh

  26. 26

    Copy files with certain extension from many nested sub-directories to a single directory and append to each copied file the name of the directory

  27. 27

    Windows script to delete and copy file to multiple directories

  28. 28

    Copy Single file to multiple directories [overwrite if there]

  29. 29

    Batch copy a specific file to all directories and subdirectories

HotTag

Archive