-1

I am trying to copy one .txt file into a large amount of folders. To do this I am trying to use robocopy, but maybe there is a better way since I am only trying to copy one file (stress_strain_example.txt).

To do this, I have the file I want to copy in A separate folder. I then have around 1,000+ folders I want to copy this file into, in a different directory than the file.

I ended up getting this code to work without tripping an error, but it copied the file outside of the folders. I am curious if I am making an error or there is an easier way.

I call robocopy and list the folder where the .txt file is, and then this destination directory where all of the folders are located. I understand that the code copies the file in that directory, but I am not sure how to get it copied into every single folder in the destination.

C:\>robocopy "C:\Py Practice\STRSTRex" "C:\Py Practice\ROTATED FILES" *.txt /S

1 Answers1

0

AFAIK robocopy only supports one source and one destination folder, so your solution requires repeating the command once for each destination folder. A batch file with a loop might accomplish this if all your destination folders are contained in a parent folder AND you either have no other child folders or can exclude unwanted destinations using the /XD (exclude directory) option.

MJA
  • 350
  • 1
  • 3
  • 15