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
我想要它,所以我可以讓他們寫一個名字的一部分,它說有一個名稱的結果。然後可能會告訴用戶哪些歌曲符合搜索條件。 –
他說它應該可以正常工作,因爲你無法在文件名中使用''''你有特定的錯誤或問題嗎? –