我试着写了一个,脚本的不重复周期通过 loop 变量控制,默认周期为七天。
每天的运行次数不限,只要你的歌库数量足够。
调用的播放器由系统设置的默认支持的播放器决定。
默认支持的歌曲类型: flac / mp3 / wav / ape , 其他格式可自行添加。
周期之内如果所有歌曲都被播放过,再次运行会提示 “所有歌曲都已经播放过一遍了”
脚本会设置一个系统环境变量 “playConfig”, 如果与已有系统环境变量冲突,请自行修改!
脚本代码: | @echo off&mode con cols=20 lines=2&color a&setlocal enabledelayedexpansion | | | | set loop=7 | | set str=%date:/=% | | set now=%str:~0,8% | | set config=%now%;1;1;0 | | | | for /r %%i in (*.flac *.mp3 *.wav *.ape) do set /a total+=1 | | echo # 歌曲列表 >list.txt | | dir *.flac *.mp3 *.wav *.ape /s /b >>list.txt | | set /a total+=1 | | | | if NOT DEFINED playConfig ( | | setx /m playConfig "%config%" >nul | | set playConfig=%config% | | ) | | | | for /f "eol=# delims=; tokens=1,2,3,4" %%i in ("%playConfig%") do ( | | set d=%%i | | set c=%%k | | set /a t=%%j | | set nums=%%l | | if "%%i" neq "%now%" ( | | set /a t=%%j+1 | | set d=%now% | | ) | | ) | | | | :rand | | set /a randNum=%random%%%!total! | | | | :start | | if !c! geq !total! echo 所有歌曲都已经播放过一遍啦! & pause>nul & goto :eof | | for %%i in (!nums!) do if %%i == %randNum% goto rand | | set /a c+=1 | | if !t! leq %loop% set config=!d!;!t!;!c!;!nums! | | setx /m playConfig "%config%,%randNum%" >nul | | for /f "skip=%randNum% delims=" %%i in (list.txt) do start "" "%%i" & goto :eofCOPY |
|