Windows: delete the source files and copy the contents of the selected folders at random using batches

  • Delete all .ext files in the source folder
  • Select the folder at random either by naming pattern or by any other means.
  • Then copy all * .ext files from the selected folder at random to the source folder [if easier can just copy whole folder contents].
  • To be executed as a batch file in a Windows environment.

Sample batch script (I still have no idea how to code): delete-and-copy.cmd

call from C:  test  source  *. ext
Call copy * .ext C:  test  library  group_% RANDOM% [COUNT=Folders %RANDOM%=Select1(%COUNT%)] "C:  test  source "

Or another suggestion does not work:

call from C:  test  source  *. ext
@echo off
setlocal EnableDelayedExpansion
cd C:  test  library 
set n = 0
for %% f in (* .ext) do (
set / A n + = 1
set "folder[!n!]= %% f "
set / A "rand = (n *% random%) / Count_1 _% _ 10"
copy "! group_[%rand%]! / *. ext "C:  test  source 

Folder design

C:  test  source  delete-and-copy.cmd
C:  test  source  (150 * .ext files plus some others)
C:  test  library  group_01  (150 * .ext Files)
C:  test  library  group_02  (150 * .ext Files)
C:  test  library  group_03  (etc.)
C:  test  library  group_04 
C:  test  library  group_05 
C:  test  library  group_06 
C:  test  library  group_07 
C:  test  library  group_08 
C:  test  library  group_09  (...)
C:  test  library  group_10  (127 * .ext Files)

Current research: