Copying a file into multiple folders

Solved
jth Posted messages 6 Registration date   Status Member Last intervention   -  
dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   -
Hello,
My question is simple:
In a folder named Video, I have 350 folders and a file "test.avi". I would like to use a batch file to copy the test file into the 350 folders.
If someone can explain how to do this, assuming it's possible, that would be nice.
Thank you for your help

Configuration: Windows 7 / Firefox 13.0.1

6 answers

  1. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
     
    hello
    from the DOS command line
    for /d %%a in (*.*) do @copy test.avi %%a
    from a .bat file replace %a with %%a
    4
  2. jth Posted messages 6 Registration date   Status Member Last intervention   2
     
    I tried the DOS command in a bat file saved in my Video folder by modifying as indicated "%%a" but it doesn't work... do I need to modify something else?
    Thank you for your help.
    2
    1. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
       
      ```html
      @echo off for /d %%a in (*.*) do copy test.avi "%%a"
      ```
      0
  3. jth Posted messages 6 Registration date   Status Member Last intervention   2
     
    Thank you for your response, but I'm sorry I have no knowledge of programming and I don't know how to use your help...
    0
  4. jth Posted messages 6 Registration date   Status Member Last intervention   2
     
    Thank you for this response, it works with the bat file, and it will save me from a tedious copying job.
    0
  5. nico_soul Posted messages 5 Status Member
     
    Hello,

    Based on this (old) discussion:
    I want to copy a folder into several directories but not all! For example, the program would only copy into the folders resulting from a previously created list (Excel, Word, Notepad, other???).

    What command should be integrated for the program to read this list and distribute the folder only into the listed directories?

    Thank you for your help :)
    0
    1. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
       
      The file liste.txt contains the list of destinations, one per line
      @echo off
      set name=name of the file
      for /F "delims=" %%a in (liste.txt) do copy "%name%" "%%a\%name%"
      0
    2. nico_soul Posted messages 5 Status Member
       
      Thank you very much, it works perfectly!
      However, does the list absolutely have to be in ".txt"? Because I tried with Excel and a Word document, but it didn't work...

      Thanks again!
      0
    3. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
       
      Yes, a for loop can only read text.
      0
    4. nico_soul Posted messages 5 Status Member
       
      ok thanks.
      Fortunately, we can directly export this txt file from Excel :)
      0
    5. nico_soul Posted messages 5 Status Member
       
      Hello,

      When I execute the multiple copy from the list and the program does not find the corresponding folders (typographical error in the list, omission...), there is a message in the dialog box notifying me. My question is the following: is it possible to automatically retrieve this text and put it in a text file (for example "Report") and display it automatically?
      Thank you for your help!
      0
  6. heyquem Posted messages 808 Status Member 131
     
    and in Python?

    from os import walk from shutil import copy dn = 'I:\\Prov Python\\' for subdn in walk(dn).next()[1]: copy(dn + 'test.txt', dn + subdn)


    walk() is a recursive generator of triplets (directory path, subdirectories, files)
    By applying next(), we get the first triplet. To obtain the list of subdirectories, we need to take index 1.
    -1