I have a CSV file with a list of several hundred music tracks and would like extract 100 pieces randomly. I am completely new to bacth scripting.
The creation of the table is correct but I would like to be able to make it random and not duplicated.
The second FOR (in :RANDOMIZE) doesn't echo anything
@ECHO OFF
setlocal enabledelayedexpansion
set _total=0
set _max=100
for /f "skip=1 tokens=11 usebackq delims=;" %%I in ("playlist.csv") do (
set _filepath=%%~I
set _ext=%%~xI
if "!_ext!"==".flac" CALL :ADDARRAY
if "!_ext!"==".mp3" CALL :ADDARRAY
)
:RANDOMIZE
for %%a in (%_array%) do (
set /A _total+=1
echo %%a
if "!_total!"=="!max!" @goto :eof
)
:ADDARRAY
set /A _cpt+=1
set _array[!_cpt!]=!_filepath!
@goto :eof
Aucun commentaire:
Enregistrer un commentaire