0
@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部分”问题是,当保存一个变量时,它不能使用'',或者他们将保存为字符串的一部分。如何将文件名保存到cmd中的变量中?
文件名不能包含少数字符,引号就是其中之一。你打算验证他们输入的每个字符是否是有效的文件名字符? – Squashman
我想要它,所以我可以让他们写一个名字的一部分,它说有一个名称的结果。然后可能会告诉用户哪些歌曲符合搜索条件。 –
他说它应该可以正常工作,因为你无法在文件名中使用''''你有特定的错误或问题吗? –