Search code examples
filedoscopying

DOS COPY the first file in a directory


How to copy the first file in any directory starting with .rar extension?


Solution

  • This will copy "the first .rar" file found" (randomly selected, for all I know) in the current folder to C:\Temp. I'd consider this to be a template you can start with.

    @ECHO OFF
    CLS
    
    FOR %%A in (*.rar) do (
       COPY %%A  C:\temp
       GOTO :Exit
    )
    
    :Exit