Need to create a batch file to select one random file from a folder and copy to another folder
10,698
Solution 1
@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
Solution 2
@echo off
set/a %%/folder
/a copy <folder2>
Author by
Admin
Updated on June 05, 2022Comments
-
Admin almost 2 years
I need to create a batch file for Windows OS that will select a random file from a particular folder, then copy that file to a different folder. I still need a copy of that file to remain in the original location.
FYI, it needs to be a batch file.
Thanks in advance for your help...