四个月之前一起讨论过随机获取文件名的方法,发现最好的代码是:
一个关于随机获取文件名的问题
24 楼无奈何版主的代码:
@echo off
if "%1" NEQ "$" (
for /f "tokens=1,2 delims=:" %%a in ('"%~0" $^|sort') do @echo %%b
) else for /f "delims=" %%i in ('dir /b /a-d *.mp3') do @call :sub %%i
goto :EOF
:sub
echo %random%:%*
goto :EOF
及后面大家修改的代码
今晚从:
[精彩][批处理字符出现次数统计]
15 楼 redtek 的 “set .”特殊用法(排序)的灵感:
@echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%i in ('dir/a-d/b *.mp3') do set $!random!!random!$%%i=$
for /f "tokens=1,2* delims=$=" %%i in ('set $') do echo %%j
pause
Four months ago, we discussed the method of randomly obtaining file names together and found that the best code is:
A question about randomly obtaining file names
The code from moderator Wunaihe on floor 24:
@echo off
if "%1" NEQ "$" (
for /f "tokens=1,2 delims=:" %%a in ('"%~0" $^|sort') do @echo %%b
) else for /f "delims=" %%i in ('dir /b /a-d *.mp3') do @call :sub %%i
goto :EOF
:sub
echo %random%:%*
goto :EOF
And the codes modified by everyone later
Tonight, inspired by the "set ." special usage (sorting) from redtek on floor 15 in:
@echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%i in ('dir/a-d/b *.mp3') do set $!random!!random!$%%i=$
for /f "tokens=1,2* delims=$=" %%i in ('set $') do echo %%j
pause