Windows下使用批处理随机播放文件
@echo off
setlocal enabledelayedexpansionset SERVER_IP=10.85.11.2
set PORT=12345:: 初始化变量
set i=0:parse_args
if "%~1"=="" goto build_done:: 判断是否是目录
if exist "%~1\" (pushd "%~1" >nul 2>nulfor /r %%f in (*) do (set /a i+=1set "arg[!i!]=%%~ff")popd
) else if exist "%~1" (set /a i+=1set "arg[!i!]=%~1"
)shift
goto parse_args:build_done
if %i%==0 (echo No valid files found.pauseexit /b
)
set count=%i%:: 无限随机播放
:loop
set /a randIndex=%random% %% count + 1
call set "filepath=%%arg[!randIndex!]%%"title !filepath!
ffmpeg.exe -re -i "!filepath!" -f wav tcp://%SERVER_IP%:%PORT%
goto loop
本文来自博客园,作者:项希盛,转载请注明原文链接:https://www.cnblogs.com/xiangxisheng/p/19006884