Note that there are some explanatory texts on larger screens.

plurals
  1. POCopy 1 file from multiple subdirectories to another directory
    primarykey
    data
    text
    <p>I've searched Google and forums for days trying to figure out how to accomplish building a batch file that will parse a directory tree and copy 1 file from each subdirectory to a new folder.</p> <p>I've got this as a lead: <a href="http://www.pcreview.co.uk/forums/can-copy-file-multiple-folders-t1959548.html" rel="nofollow noreferrer">http://www.pcreview.co.uk/forums/can-copy-file-multiple-folders-t1959548.html</a></p> <p>and this... <a href="https://stackoverflow.com/questions/1...in-a-directory">https://stackoverflow.com/questions/1...in-a-directory</a></p> <p>And I've tried this:</p> <pre><code>@ECHO OFF CLS PAUSE FOR /R %%A in (C:\Users\Liam\Desktop\Master) DO ( COPY %%A C:\Users\Liam\Desktop\Master\Master-Copies\ GOTO :Exit ) :Exit Pause </code></pre> <p>The pauses are present because I'm trying to figure out exactly what is occurring.</p> <p>Within my "Master" directory there are about 250 subdirectories. I'd like to copy a single file from each subdirectory and put them in a new subdirectory called "Master-Copies", which should ultimately have 250 files. The subdirectories and files don't have spaces in their names, however I'd like to build that functionality into the batch file in case I ever run into this situation again. I'd like to copy the first file in each subdirectory. I know from reading other forums that the "FIRST" file is relative, but I'd like it to be the first file sorted by name.</p> <p>I know I'm asking a lot, and hopefully some genius here can help out a kid new to programming.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload