我又让Ai帮你做了个,让你可以选择最近7天的菜单去播放。
我测试了一下,还挺不错。- @echo off
- setlocal enabledelayedexpansion
-
- rem 获取今天的日期并格式化为YYYYMMDD
- for /f "tokens=1-3 delims=/" %%a in ("%date%") do (
- set "year=%%a"
- set "month=%%b"
- set "day=%%c"
- )
-
- rem 去掉星期几信息,设置文件夹路径
- set "datevar=!year!!month!!day!"
- set "datevar=!datevar:~0,8!" rem 仅保留年月日部分
-
- echo.
- echo 请选择需要播放的日期:
- echo.
- rem 创建日期菜单
- for /l %%i in (1,1,7) do (
- set "nextDate=!datevar:~0,4!!datevar:~4,2!!datevar:~6,2!"
- echo [%%i] !nextDate!
- if %%i lss 7 echo.
- set /a "datevar=datevar + 1"
- )
-
- echo.
- set /p "choice=请选择要播放音乐的日期(1-7): "
- if "%choice%" geq "1" if "%choice%" leq "7" (
- rem 获取选择菜单上的日期并构建路径
- set /a "selectedDate=%choice%-1"
- set "datePath="
- set /a "day=%date:~8,2%+selectedDate"
- set "month=%date:~5,2%"
- set "year=%date:~0,4%"
-
- rem 设置文件夹路径
- set "datevar3=!year!!month!!day!"
- set "datePath=D:\mp3\!datevar3!"
-
- rem 检查日期路径是否存在
- if exist "!datePath!" (
- rem 启动 PotPlayer Mini 播放该路径下的音乐
- start "" "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" "!datePath!" /autoplay
- ) else (
- echo 文件夹 "!datePath!" 不存在。
- )
- ) else (
- echo 无效的选择。
- )
-
- endlocal
复制代码
|