General discussion

Locked

Copy file to all subfolders in a folder?

By 4sommers ·
Is there a way to copy a file to all subdirectories in a particular directory? I'm looking for a command-line entry, something that can be done from a batch file.
Thanks.

This conversation is currently closed to new comments.

10 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Copy file to all subfolders in a folder?

by jjordan In reply to Copy file to all subfolde ...

Sorry their is not a command-line to do this.

Collapse -

Copy file to all subfolders in a folder?

by 4sommers In reply to Copy file to all subfolde ...

Poster rated this answer

Collapse -

Copy file to all subfolders in a folder?

by mphoffar In reply to Copy file to all subfolde ...

xcopy .e *.* c:\copied

This will copy all files and subdirectories to th elocation c:\copied keeping hte directory structure

Hope that helps

Mark

Collapse -

Copy file to all subfolders in a folder?

by 4sommers In reply to Copy file to all subfolde ...

Poster rated this answer

Collapse -

Copy file to all subfolders in a folder?

by Mark In reply to Copy file to all subfolde ...

I am not sure why you would want to do that, but I use an old DOS utility called "SWEEP" that repeats the same DOS command in each subfolder. You could do a sweep copy <\filename> <path\newfilename> and it would do what you are asking. You can get this utility from ftp://ftp.primocom.com/Software/Util/

If you want to do backups use this:
XCOPY32 C:\source D:\destination /C /D /R /S > D:\destination\incbacup.log

Source and destination are the directories with your personal files on
thesource and destination hard disks, respectively. The /S switch will
include subdirectories, the /R will include read-only files too, the /D
switch without a date will copy new or newer files only, and the /C
switch will continue the operation even if an error occurred.
Incbacup.log is the name of the log file created by XCOPY32 with the
names of all the files it copied. Substitute the appropriate names for
the source, destination, and log files on your computer system. For
more information on the command line switches see the XCOPY32 command.

Collapse -

Copy file to all subfolders in a folder?

by 4sommers In reply to Copy file to all subfolde ...
Collapse -

Copy file to all subfolders in a folder?

by emcs In reply to Copy file to all subfolde ...

If I understand you problem, here is a solution:

1. Create a file with all of the subdirectories where you want the one file to be copied. You can create the file manually or because all of the subdirectories are in one path do the following:
a.Go to the where the subdirectory tree starts.
b. Type in the following command:
dir /ad /s /b > filename1.
Filename1 can be any name you choose.

2. Create a batch file with the following line: for /F %%i IN (filename1) do copy filename2 %%i
Filename2 is the file you want to copy.

3. Run the batch file. This will put filename2 in each subdirectory that is in filename1.

This batch file can also be ran at the same time everyday.

I know this works. Leat me know if you have problems.

dennie

Collapse -

Copy file to all subfolders in a folder?

by 4sommers In reply to Copy file to all subfolde ...
Collapse -

Regarding ur code

by akStrider In reply to Copy file to all subfolde ...

Can u pls explain ur code and what each command does so that I can customize it to suit my need. Tnx

Collapse -

Copy file to all subfolders in a folder?

by 4sommers In reply to Copy file to all subfolde ...

This question was closed by the author

Back to Windows Forum
10 total posts (Page 1 of 1)  

Operating Systems Forums