The code below is suppose to take 1 file out of each sub directory in d:\test and put them in f:\source, it does this but the randomization part isn't working. Each file from each folder gets picked based on creation date, and the last "created" file in each folder is always the ones that appear in f:\source.
Any ideas why?
setlocal EnableDelayedExpansion cd D:\test set t=0 for /d %%i in () do ( cd "%%i" set /A t+=1 set n[!t!]=0 for %%f in (.) do ( set /A n[!t!]+=1 set "file[!n!]=%%f" ) set /A "rand=(n[!t!]%random%)/32768+1" copy "!file[%rand%]!" f:\source cd.. ) pause
Aucun commentaire:
Enregistrer un commentaire