As for the "numbering" issue in Moderator 无奈何's code that voiL mentioned in post #10, I guess voiL appended >>List.txt after the line “echo %random%:%*”, whereas it should have been appended after “@echo %%b”
See post #25
See post #25
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
DigestI
View 17,410 Replies 54
Originally posted by zxcv at 2006-7-28 09:42:
Honestly, I added those when posting to explain what each line does. They were never in the real BAT to begin with (which is why I said: don't include the red parts); but you should be able to tell whi...
@echo off
setlocal enabledelayedexpansion
copy nul List.txt >NUL
if "%1" NEQ "$" (
for /f "tokens=1,2 delims=:" %%a in ('"%~0" $^|sort') do echo %%b>>List.txt
) else for /f "delims=" %%i in ('dir /b /a-d *.mp3') do echo !random!:%%i
@echo off
copy nul List.txt >NUL
if "%1" NEQ "$" (
for /f "tokens=1,2 delims=:" %%a in ('"%~0" $^|sort') do echo %%b>>List.txt
) else for /f "delims=" %%i in ('dir /b /a-d *.mp3') do call echo %%random%%:%%%%i
Originally posted by 无奈何 at 2006-7-27 23:51:
@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') do @call :sub %%i
goto :EOF
:sub
echo %random%:%*
goto :EOF
Originally posted by 220110 at 2006-7-28 10:01:
To obtain the total number of mp3 files in the directory, use for /r %%i in (*.mp3) do set /a n+=1 to replace:
for /f "tokens=1 delims= " %%i in ('dir *.mp3^|find "个文件"') do set 文件数量=%%i
dir /b *.mp3 | findstr /n "." >tem.txt
for /f "tokens=1 delims=:" %%g in (tem.txt) do set maxnum=%%g
for /f "delims=" %%i in ('dir /b /a-d') do @call :sub %%i
Would that be a bit more efficient? Please have willssort do a deeper analysis.
@echo off & setlocal
dir %1 /a/s/w/-c | findstr "个文件">temp.txt
for /f %%i in (temp.txt) do set filenum=%%i
echo.FileNum:%filenum%
if exist temp.txt del temp.txt
@echo off
cd.>temp.txt & cd.>list.txt
for /f "delims=" %%i in ('dir *.mp3 /b/a-d') do call echo %%random%%%%random%%:%%i>>temp.txt
sort < temp.txt > temp1.txt
for /f "tokens=1,2 delims=:" %%a in (temp1.txt) do echo %%b>>list.txt
for %%f in (temp?.txt) do del %%f
@echo off
for /f "delims=" %%i in ('dir/a-d/b *.mp3') do call set $%%random%%$%%i=$
for /f "tokens=1,2* delims=$=" %%i in ('set $') do echo %%j
pause@echo off
set /a num=%random% %% 4 + 1
dir /b /a-d | sort /+%num%
pause
exit /b 0