@echo off
title Music
color 0f
:main
cls
echo Welcome to you Music!
echo.
set /p var=What would you like to do:
if %var%==find goto find
if %var%==play goto play
goto main
:find
cls
set /p song=What song would you like me to check for (Case Sensitive):
if exist music\"*%song%*.mp3" goto exist
if not exist music\"*%song%*.mp3" goto notExist
:exist
cls
echo %song% is here.
echo.
pause
goto main
:notExist
cls
echo %song% is not here. Check the spelling and letter case for errors.
echo.
pause
goto main
:play
cls
set /p song=Enter the name of a song to play:
if exist music\"*%song%*.mp3" goto play2
if not exist music\"*%song%*.mp3" goto notExist
goto main
:play2
cls
set songName = [file name]
:playing
:: Will put more code later.
此程序的目的是在我的音乐中搜索特定的歌曲,并能够从命令行播放它。我稍后会添加代码来控制音乐但是现在我只想找到这首歌并播放它。我正在使用' '所以有人可以进入墙上的另一块砖"然后让它找到“墙上的另一块砖”第2部分"问题是在保存变量时,它不能使用' '或者它们将被保存为字符串的一部分。
答案 0 :(得分:0)
你的问题不是很清楚。以下内容应该回答我从您的问题和评论中猜到的内容:
set /p "song=What song would you like me to check for (Case insensitive): "
REM if you are afraid of qoutes entered by the user, remove them:
set song=%song:"=%
<nul set /p "=Songs found: "
dir /b "music\*%song%*.mp3"|find /c /v ""
echo the names are:
dir /b "music\*%song%*.mp3"
echo executing them...
for /f "delims=" %%i in ('dir /b /s "music\*%song%*.mp3"') do (
echo ... executing %%i
REM whatever you use to play it
)