Reputation: 31
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...
Upvotes: 2
Views: 11813
Reputation: 67216
@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
Upvotes: 6