You must create a batch file to select one random file from a folder and copy to another folder

I need to create a batch file for Windows, which will select a random file from a specific folder, and then copy this file to another folder. I still need a copy of this file to stay in its original location.

FYI, this must be a batch file.

Thanks in advance for your help ...

+2
source share
2 answers
@echo off setlocal EnableDelayedExpansion cd \particular\folder set n=0 for %%f in (*.*) do ( set /A n+=1 set "file[!n!]=%%f" ) set /A "rand=(n*%random%)/32768+1" copy "!file[%rand%]!" \different\folder 
+3
source
 @echo off set/a %%/folder /a copy <folder2> 
0
source

Source: https://habr.com/ru/post/1346742/


All Articles