Copy file to all subfolders in a folder?
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.
Windows Forum
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.
by mphoffar
xcopy .e *.* c:\copied
This will copy all files and subdirectories to th elocation c:\copied keeping hte directory structure
Hope that helps
Mark
by 4sommers
by mark
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> 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.
by 4sommers
by emcs
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
by 4sommers
This discussion is closed to new replies.
Sort by Trending